Rebase Conflicts

This commit is contained in:
PiotrP 2016-04-25 11:29:29 -07:00
parent 91bfc022a2
commit 44f6642116
7 changed files with 17 additions and 141 deletions

View file

@ -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; }
}
}
}

View file

@ -102,7 +102,7 @@ namespace Microsoft.DotNet.TestFramework
var testInstance = new TestInstance(testProjectDir, testDestination);
return testInstance;
}
public TestDirectory CreateTestDirectory([CallerMemberName] string callingMethod = "", string identifier = "")
{
string testDestination = Path.Combine(AppContext.BaseDirectory, callingMethod + identifier);

View file

@ -22,9 +22,9 @@ namespace Microsoft.DotNet.TestFramework
EnsureExistsAndEmpty(Path);
}
public string Path { get; private set; }
private static void EnsureExistsAndEmpty(string path)
{
if (Directory.Exists(path))

View file

@ -11,6 +11,9 @@ namespace Microsoft.DotNet.TestFramework
{
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;
internal TestInstance(string testAssetRoot, string testDestination) : base(testDestination)
@ -21,7 +24,7 @@ namespace Microsoft.DotNet.TestFramework
}
_testAssetRoot = testAssetRoot;
CopySource();
}
@ -92,8 +95,13 @@ namespace Microsoft.DotNet.TestFramework
.Where(file =>
{
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}");
var isBlackListed = BuildArtifactBlackList.Any(b => file.Contains(b));
return isArtifact && !isBlackListed;
});
foreach (string binFile in binFiles)

View file

@ -42,9 +42,9 @@ namespace Microsoft.DotNet.Cli
public static int Main(string[] args)
{
DebugHelper.HandleDebugSwitch(ref args);
new MulticoreJitActivator().TryActivateMulticoreJit();
if (Env.GetEnvironmentVariableAsBool("DOTNET_CLI_CAPTURE_TIMING", false))
{
PerfTrace.Enabled = true;

View file

@ -96,6 +96,7 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
{
Test(new string[] { }, new[] { "L21" }, workingDirectory: Path.Combine("src", "L21"));
}
[Fact]
public void TestFailsIfNoProjectJsonInCurrentDirectoryWithNoArguments()
{

View file

@ -110,7 +110,7 @@ namespace Microsoft.DotNet.Tests
var rid = PlatformServices.Default.Runtime.GetRuntimeIdentifier();
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? $@"Microsoft\dotnet\sdk\{version}{rid}\optimizationdata"
? $@"Microsoft\dotnet\sdk\{version}\{rid}\optimizationdata"
: $@".dotnet/sdk/{version}/{rid}/optimizationdata";
}