Rebase Conflicts
This commit is contained in:
parent
91bfc022a2
commit
44f6642116
7 changed files with 17 additions and 141 deletions
|
@ -1,133 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Microsoft.DotNet.TestFramework
|
|
||||||
{
|
|
||||||
public class TestInstance
|
|
||||||
{
|
|
||||||
// made tolower because the rest of the class works with normalized tolower strings
|
|
||||||
private static readonly IEnumerable<string> BuildArtifactBlackList = new List<string>() {".IncrementalCache", ".SDKVersion"}.Select(s => s.ToLower()).ToArray();
|
|
||||||
|
|
||||||
private string _testDestination;
|
|
||||||
private string _testAssetRoot;
|
|
||||||
|
|
||||||
internal TestInstance(string testAssetRoot, string testDestination)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Copying {testAssetRoot} to {testDestination}");
|
|
||||||
if (string.IsNullOrEmpty(testAssetRoot))
|
|
||||||
{
|
|
||||||
throw new ArgumentException("testScenario");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(testDestination))
|
|
||||||
{
|
|
||||||
throw new ArgumentException("testDestination");
|
|
||||||
}
|
|
||||||
|
|
||||||
_testAssetRoot = testAssetRoot;
|
|
||||||
_testDestination = testDestination;
|
|
||||||
|
|
||||||
if (Directory.Exists(testDestination))
|
|
||||||
{
|
|
||||||
Directory.Delete(testDestination, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Directory.CreateDirectory(testDestination);
|
|
||||||
CopySource();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CopySource()
|
|
||||||
{
|
|
||||||
var sourceDirs = Directory.GetDirectories(_testAssetRoot, "*", SearchOption.AllDirectories)
|
|
||||||
.Where(dir =>
|
|
||||||
{
|
|
||||||
dir = dir.ToLower();
|
|
||||||
return !dir.EndsWith($"{Path.DirectorySeparatorChar}bin")
|
|
||||||
&& !dir.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}")
|
|
||||||
&& !dir.EndsWith($"{Path.DirectorySeparatorChar}obj")
|
|
||||||
&& !dir.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}");
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (string sourceDir in sourceDirs)
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(sourceDir.Replace(_testAssetRoot, _testDestination));
|
|
||||||
}
|
|
||||||
|
|
||||||
var sourceFiles = Directory.GetFiles(_testAssetRoot, "*.*", SearchOption.AllDirectories)
|
|
||||||
.Where(file =>
|
|
||||||
{
|
|
||||||
file = file.ToLower();
|
|
||||||
return !file.EndsWith("project.lock.json")
|
|
||||||
&& !file.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}")
|
|
||||||
&& !file.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}");
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (string srcFile in sourceFiles)
|
|
||||||
{
|
|
||||||
string destFile = srcFile.Replace(_testAssetRoot, _testDestination);
|
|
||||||
File.Copy(srcFile, destFile, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TestInstance WithLockFiles()
|
|
||||||
{
|
|
||||||
foreach (string lockFile in Directory.GetFiles(_testAssetRoot, "project.lock.json", SearchOption.AllDirectories))
|
|
||||||
{
|
|
||||||
string destinationLockFile = lockFile.Replace(_testAssetRoot, _testDestination);
|
|
||||||
File.Copy(lockFile, destinationLockFile, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TestInstance WithBuildArtifacts()
|
|
||||||
{
|
|
||||||
var binDirs = Directory.GetDirectories(_testAssetRoot, "*", SearchOption.AllDirectories)
|
|
||||||
.Where(dir =>
|
|
||||||
{
|
|
||||||
dir = dir.ToLower();
|
|
||||||
return dir.EndsWith($"{Path.DirectorySeparatorChar}bin")
|
|
||||||
|| dir.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}")
|
|
||||||
|| dir.EndsWith($"{Path.DirectorySeparatorChar}obj")
|
|
||||||
|| dir.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}");
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (string dirPath in binDirs)
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(dirPath.Replace(_testAssetRoot, _testDestination));
|
|
||||||
}
|
|
||||||
|
|
||||||
var binFiles = Directory.GetFiles(_testAssetRoot, "*.*", SearchOption.AllDirectories)
|
|
||||||
.Where(file =>
|
|
||||||
{
|
|
||||||
file = file.ToLower();
|
|
||||||
|
|
||||||
var isArtifact = file.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}")
|
|
||||||
|| file.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}");
|
|
||||||
|
|
||||||
var isBlackListed = BuildArtifactBlackList.Any(b => file.Contains(b));
|
|
||||||
|
|
||||||
return isArtifact && !isBlackListed;
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (string binFile in binFiles)
|
|
||||||
{
|
|
||||||
string destFile = binFile.Replace(_testAssetRoot, _testDestination);
|
|
||||||
File.Copy(binFile, destFile, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string TestRoot
|
|
||||||
{
|
|
||||||
get { return _testDestination; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -102,7 +102,7 @@ namespace Microsoft.DotNet.TestFramework
|
||||||
var testInstance = new TestInstance(testProjectDir, testDestination);
|
var testInstance = new TestInstance(testProjectDir, testDestination);
|
||||||
return testInstance;
|
return testInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestDirectory CreateTestDirectory([CallerMemberName] string callingMethod = "", string identifier = "")
|
public TestDirectory CreateTestDirectory([CallerMemberName] string callingMethod = "", string identifier = "")
|
||||||
{
|
{
|
||||||
string testDestination = Path.Combine(AppContext.BaseDirectory, callingMethod + identifier);
|
string testDestination = Path.Combine(AppContext.BaseDirectory, callingMethod + identifier);
|
||||||
|
|
|
@ -22,9 +22,9 @@ namespace Microsoft.DotNet.TestFramework
|
||||||
|
|
||||||
EnsureExistsAndEmpty(Path);
|
EnsureExistsAndEmpty(Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Path { get; private set; }
|
public string Path { get; private set; }
|
||||||
|
|
||||||
private static void EnsureExistsAndEmpty(string path)
|
private static void EnsureExistsAndEmpty(string path)
|
||||||
{
|
{
|
||||||
if (Directory.Exists(path))
|
if (Directory.Exists(path))
|
||||||
|
|
|
@ -11,6 +11,9 @@ namespace Microsoft.DotNet.TestFramework
|
||||||
{
|
{
|
||||||
public class TestInstance: TestDirectory
|
public class TestInstance: TestDirectory
|
||||||
{
|
{
|
||||||
|
// made tolower because the rest of the class works with normalized tolower strings
|
||||||
|
private static readonly IEnumerable<string> BuildArtifactBlackList = new List<string>() {".IncrementalCache", ".SDKVersion"}.Select(s => s.ToLower()).ToArray();
|
||||||
|
|
||||||
private string _testAssetRoot;
|
private string _testAssetRoot;
|
||||||
|
|
||||||
internal TestInstance(string testAssetRoot, string testDestination) : base(testDestination)
|
internal TestInstance(string testAssetRoot, string testDestination) : base(testDestination)
|
||||||
|
@ -21,7 +24,7 @@ namespace Microsoft.DotNet.TestFramework
|
||||||
}
|
}
|
||||||
|
|
||||||
_testAssetRoot = testAssetRoot;
|
_testAssetRoot = testAssetRoot;
|
||||||
|
|
||||||
CopySource();
|
CopySource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,8 +95,13 @@ namespace Microsoft.DotNet.TestFramework
|
||||||
.Where(file =>
|
.Where(file =>
|
||||||
{
|
{
|
||||||
file = file.ToLower();
|
file = file.ToLower();
|
||||||
return file.Contains($"{System.IO.Path.DirectorySeparatorChar}bin{System.IO.Path.DirectorySeparatorChar}")
|
|
||||||
|
var isArtifact = file.Contains($"{System.IO.Path.DirectorySeparatorChar}bin{System.IO.Path.DirectorySeparatorChar}")
|
||||||
|| file.Contains($"{System.IO.Path.DirectorySeparatorChar}obj{System.IO.Path.DirectorySeparatorChar}");
|
|| file.Contains($"{System.IO.Path.DirectorySeparatorChar}obj{System.IO.Path.DirectorySeparatorChar}");
|
||||||
|
|
||||||
|
var isBlackListed = BuildArtifactBlackList.Any(b => file.Contains(b));
|
||||||
|
|
||||||
|
return isArtifact && !isBlackListed;
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (string binFile in binFiles)
|
foreach (string binFile in binFiles)
|
||||||
|
|
|
@ -42,9 +42,9 @@ namespace Microsoft.DotNet.Cli
|
||||||
public static int Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
DebugHelper.HandleDebugSwitch(ref args);
|
DebugHelper.HandleDebugSwitch(ref args);
|
||||||
|
|
||||||
new MulticoreJitActivator().TryActivateMulticoreJit();
|
new MulticoreJitActivator().TryActivateMulticoreJit();
|
||||||
|
|
||||||
if (Env.GetEnvironmentVariableAsBool("DOTNET_CLI_CAPTURE_TIMING", false))
|
if (Env.GetEnvironmentVariableAsBool("DOTNET_CLI_CAPTURE_TIMING", false))
|
||||||
{
|
{
|
||||||
PerfTrace.Enabled = true;
|
PerfTrace.Enabled = true;
|
||||||
|
|
|
@ -96,6 +96,7 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
||||||
{
|
{
|
||||||
Test(new string[] { }, new[] { "L21" }, workingDirectory: Path.Combine("src", "L21"));
|
Test(new string[] { }, new[] { "L21" }, workingDirectory: Path.Combine("src", "L21"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestFailsIfNoProjectJsonInCurrentDirectoryWithNoArguments()
|
public void TestFailsIfNoProjectJsonInCurrentDirectoryWithNoArguments()
|
||||||
{
|
{
|
||||||
|
|
|
@ -110,7 +110,7 @@ namespace Microsoft.DotNet.Tests
|
||||||
var rid = PlatformServices.Default.Runtime.GetRuntimeIdentifier();
|
var rid = PlatformServices.Default.Runtime.GetRuntimeIdentifier();
|
||||||
|
|
||||||
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
||||||
? $@"Microsoft\dotnet\sdk\{version}{rid}\optimizationdata"
|
? $@"Microsoft\dotnet\sdk\{version}\{rid}\optimizationdata"
|
||||||
: $@".dotnet/sdk/{version}/{rid}/optimizationdata";
|
: $@".dotnet/sdk/{version}/{rid}/optimizationdata";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue