Use a shorter path for test working directories, get rid of Stage 0 project.json based CLI
This commit is contained in:
parent
fd66cdcc2f
commit
4c3b13e4a8
8 changed files with 32 additions and 313 deletions
|
@ -53,18 +53,6 @@ if (!(Test-Path $env:DOTNET_INSTALL_DIR))
|
|||
mkdir $env:DOTNET_INSTALL_DIR | Out-Null
|
||||
}
|
||||
|
||||
# We also need to pull down a project.json based CLI that is used by some tests
|
||||
# so create another directory for that.
|
||||
if (!$env:DOTNET_INSTALL_DIR_PJ)
|
||||
{
|
||||
$env:DOTNET_INSTALL_DIR_PJ="$RepoRoot\.dotnet_stage0PJ\$Architecture"
|
||||
}
|
||||
|
||||
if (!(Test-Path $env:DOTNET_INSTALL_DIR_PJ))
|
||||
{
|
||||
mkdir $env:DOTNET_INSTALL_DIR_PJ | Out-Null
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Disable first run since we want to control all package sources
|
||||
|
@ -88,14 +76,6 @@ if ($LastExitCode -ne 0)
|
|||
exit $LastExitCode
|
||||
}
|
||||
|
||||
Write-Output "$dotnetInstallPath -Channel ""master"" -InstallDir $env:DOTNET_INSTALL_DIR_PJ -Architecture ""$Architecture"" -Version 1.0.0-preview2-1-003177"
|
||||
Invoke-Expression "$dotnetInstallPath -Channel ""master"" -InstallDir $env:DOTNET_INSTALL_DIR_PJ -Architecture ""$Architecture"" -Version 1.0.0-preview2-1-003177"
|
||||
if ($LastExitCode -ne 0)
|
||||
{
|
||||
Write-Output "The .NET CLI installation failed with exit code $LastExitCode"
|
||||
exit $LastExitCode
|
||||
}
|
||||
|
||||
# Put the stage0 on the path
|
||||
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
|
||||
|
||||
|
|
13
run-build.sh
13
run-build.sh
|
@ -139,11 +139,6 @@ args=($temp)
|
|||
[ -z "$DOTNET_INSTALL_DIR" ] && export DOTNET_INSTALL_DIR=$REPOROOT/.dotnet_stage0/$ARCHITECTURE
|
||||
[ -d "$DOTNET_INSTALL_DIR" ] || mkdir -p $DOTNET_INSTALL_DIR
|
||||
|
||||
# We also need to pull down a project.json based CLI that is used by some tests
|
||||
# so create another directory for that.
|
||||
[ -z "$DOTNET_INSTALL_DIR_PJ" ] && export DOTNET_INSTALL_DIR_PJ=$REPOROOT/.dotnet_stage0PJ/$ARCHITECTURE
|
||||
[ -d "$DOTNET_INSTALL_DIR_PJ" ] || mkdir -p $DOTNET_INSTALL_DIR_PJ
|
||||
|
||||
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
||||
|
||||
# Enable verbose VS Test Console logging
|
||||
|
@ -163,14 +158,6 @@ if [ $EXIT_CODE != 0 ]; then
|
|||
exit $EXIT_CODE
|
||||
fi
|
||||
|
||||
# Install a project.json based CLI for use by tests
|
||||
(set -x ; "$REPOROOT/scripts/obtain/dotnet-install.sh" --channel "master" --install-dir "$DOTNET_INSTALL_DIR_PJ" --architecture "$ARCHITECTURE" --version "1.0.0-preview2-1-003177")
|
||||
EXIT_CODE=$?
|
||||
if [ $EXIT_CODE != 0 ]; then
|
||||
echo "run-build: Error: installing project-json based cli failed with exit code $EXIT_CODE." >&2
|
||||
exit $EXIT_CODE
|
||||
fi
|
||||
|
||||
# Put stage 0 on the PATH (for this shell only)
|
||||
PATH="$DOTNET_INSTALL_DIR:$PATH"
|
||||
|
||||
|
|
|
@ -15,13 +15,15 @@ namespace Microsoft.DotNet.TestFramework
|
|||
|
||||
public string AssetName { get; private set; }
|
||||
|
||||
public FileInfo DotnetExeFile { get; private set; }
|
||||
public FileInfo DotnetExeFile => _testAssets.DotnetCsprojExe;
|
||||
|
||||
public string ProjectFilePattern { get; private set; }
|
||||
public string ProjectFilePattern => "*.csproj";
|
||||
|
||||
public DirectoryInfo Root { get; private set; }
|
||||
|
||||
internal TestAssetInfo(DirectoryInfo root, string assetName, FileInfo dotnetExeFile, string projectFilePattern)
|
||||
private TestAssets _testAssets { get; }
|
||||
|
||||
internal TestAssetInfo(DirectoryInfo root, string assetName, TestAssets testAssets)
|
||||
{
|
||||
if (root == null)
|
||||
{
|
||||
|
@ -33,23 +35,16 @@ namespace Microsoft.DotNet.TestFramework
|
|||
throw new ArgumentException("Argument cannot be null or whitespace", nameof(assetName));
|
||||
}
|
||||
|
||||
if (dotnetExeFile == null)
|
||||
if (testAssets == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(dotnetExeFile));
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(projectFilePattern))
|
||||
{
|
||||
throw new ArgumentException("Argument cannot be null or whitespace", nameof(projectFilePattern));
|
||||
throw new ArgumentNullException(nameof(testAssets));
|
||||
}
|
||||
|
||||
Root = root;
|
||||
|
||||
AssetName = assetName;
|
||||
|
||||
DotnetExeFile = dotnetExeFile;
|
||||
|
||||
ProjectFilePattern = projectFilePattern;
|
||||
_testAssets = testAssets;
|
||||
}
|
||||
|
||||
public TestAssetInstance CreateInstance([CallerMemberName] string callingMethod = "", string identifier = "")
|
||||
|
@ -71,12 +66,7 @@ namespace Microsoft.DotNet.TestFramework
|
|||
|
||||
private DirectoryInfo GetTestDestinationDirectory(string callingMethod, string identifier)
|
||||
{
|
||||
#if NET451
|
||||
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
#else
|
||||
string baseDirectory = AppContext.BaseDirectory;
|
||||
#endif
|
||||
return new DirectoryInfo(Path.Combine(baseDirectory, callingMethod + identifier, AssetName));
|
||||
return _testAssets.CreateTestDirectory(AssetName, callingMethod, identifier);
|
||||
}
|
||||
|
||||
private void ThrowIfTestAssetDoesNotExist()
|
||||
|
|
|
@ -17,13 +17,11 @@ namespace Microsoft.DotNet.TestFramework
|
|||
|
||||
private FileInfo _dotnetCsprojExe;
|
||||
|
||||
private FileInfo _dotnetProjectJsonExe;
|
||||
private string _testWorkingFolder;
|
||||
|
||||
private const string ProjectJsonSearchPattern = "project.json";
|
||||
public FileInfo DotnetCsprojExe => _dotnetCsprojExe;
|
||||
|
||||
private const string CsprojSearchPattern = "*.csproj";
|
||||
|
||||
public TestAssets(DirectoryInfo assetsRoot, FileInfo dotnetCsprojExe, FileInfo dotnetProjectJsonExe)
|
||||
public TestAssets(DirectoryInfo assetsRoot, FileInfo dotnetCsprojExe, string testWorkingFolder)
|
||||
{
|
||||
if (assetsRoot == null)
|
||||
{
|
||||
|
@ -35,11 +33,6 @@ namespace Microsoft.DotNet.TestFramework
|
|||
throw new ArgumentNullException(nameof(dotnetCsprojExe));
|
||||
}
|
||||
|
||||
if (dotnetProjectJsonExe == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(dotnetProjectJsonExe));
|
||||
}
|
||||
|
||||
if (!assetsRoot.Exists)
|
||||
{
|
||||
throw new DirectoryNotFoundException($"Directory not found at '{assetsRoot}'");
|
||||
|
@ -50,16 +43,10 @@ namespace Microsoft.DotNet.TestFramework
|
|||
throw new FileNotFoundException("Csproj dotnet executable must exist", dotnetCsprojExe.FullName);
|
||||
}
|
||||
|
||||
if (!dotnetProjectJsonExe.Exists)
|
||||
{
|
||||
throw new FileNotFoundException("project.json dotnet executable must exist", dotnetProjectJsonExe.FullName);
|
||||
}
|
||||
|
||||
_root = assetsRoot;
|
||||
|
||||
_dotnetCsprojExe = dotnetCsprojExe;
|
||||
|
||||
_dotnetProjectJsonExe = dotnetProjectJsonExe;
|
||||
_testWorkingFolder = testWorkingFolder;
|
||||
}
|
||||
|
||||
public TestAssetInfo Get(string name)
|
||||
|
@ -74,24 +61,7 @@ namespace Microsoft.DotNet.TestFramework
|
|||
return new TestAssetInfo(
|
||||
assetDirectory,
|
||||
name,
|
||||
_dotnetCsprojExe,
|
||||
CsprojSearchPattern);
|
||||
}
|
||||
|
||||
public TestAssetInfo GetProjectJson(string name)
|
||||
{
|
||||
return GetProjectJson(TestAssetKinds.TestProjects, name);
|
||||
}
|
||||
|
||||
public TestAssetInfo GetProjectJson(string kind, string name)
|
||||
{
|
||||
var assetDirectory = new DirectoryInfo(Path.Combine(_root.FullName, kind, name));
|
||||
|
||||
return new TestAssetInfo(
|
||||
assetDirectory,
|
||||
name,
|
||||
_dotnetProjectJsonExe,
|
||||
ProjectJsonSearchPattern);
|
||||
this);
|
||||
}
|
||||
|
||||
public DirectoryInfo CreateTestDirectory(string testProjectName = "temp", [CallerMemberName] string callingMethod = "", string identifier = "")
|
||||
|
@ -112,7 +82,10 @@ namespace Microsoft.DotNet.TestFramework
|
|||
#else
|
||||
string baseDirectory = AppContext.BaseDirectory;
|
||||
#endif
|
||||
return Path.Combine(baseDirectory, callingMethod + identifier, testProjectName);
|
||||
// Find the name of the assembly the test comes from based on the the base directory and how the output path has been constructed
|
||||
string testAssemblyName = new DirectoryInfo(baseDirectory).Parent.Parent.Name;
|
||||
|
||||
return Path.Combine(_testWorkingFolder, testAssemblyName, callingMethod + identifier, testProjectName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,183 +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.IO;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||
{
|
||||
public sealed class BuildPJCommand : TestCommand
|
||||
{
|
||||
|
||||
private bool _captureOutput;
|
||||
|
||||
private string _configuration;
|
||||
|
||||
private NuGetFramework _framework;
|
||||
|
||||
private string _runtime;
|
||||
|
||||
private bool _noDependencies;
|
||||
|
||||
private DirectoryInfo _outputPath;
|
||||
|
||||
private FileInfo _projectFile;
|
||||
|
||||
private DirectoryInfo _workingDirectory;
|
||||
|
||||
public BuildPJCommand()
|
||||
: base(new RepoDirectoriesProvider().PjDotnet)
|
||||
{
|
||||
}
|
||||
|
||||
public override CommandResult Execute(string args = "")
|
||||
{
|
||||
args = $"build {GetNoDependencies()} {GetProjectFile()} {GetOutputPath()} {GetConfiguration()} {GetFramework()} {GetRuntime()} {args}";
|
||||
|
||||
if (_workingDirectory != null)
|
||||
{
|
||||
this.WithWorkingDirectory(_workingDirectory.FullName);
|
||||
}
|
||||
|
||||
if (_captureOutput)
|
||||
{
|
||||
return base.ExecuteWithCapturedOutput(args);
|
||||
}
|
||||
else
|
||||
{
|
||||
return base.Execute(args);
|
||||
}
|
||||
}
|
||||
|
||||
public override CommandResult ExecuteWithCapturedOutput(string args = "")
|
||||
{
|
||||
WithCapturedOutput();
|
||||
|
||||
return Execute(args);
|
||||
}
|
||||
|
||||
public BuildPJCommand WithCapturedOutput()
|
||||
{
|
||||
_captureOutput = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildPJCommand WithConfiguration(string configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildPJCommand WithFramework(NuGetFramework framework)
|
||||
{
|
||||
_framework = framework;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildPJCommand WithRuntime(string runtime)
|
||||
{
|
||||
_runtime = runtime;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildPJCommand WithNoDependencies()
|
||||
{
|
||||
_noDependencies = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildPJCommand WithOutputPath(DirectoryInfo outputPath)
|
||||
{
|
||||
_outputPath = outputPath;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildPJCommand WithProjectDirectory(DirectoryInfo projectDirectory)
|
||||
{
|
||||
_workingDirectory = projectDirectory;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildPJCommand WithProjectFile(FileInfo projectFile)
|
||||
{
|
||||
_projectFile = projectFile;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildPJCommand WithWorkingDirectory(DirectoryInfo workingDirectory)
|
||||
{
|
||||
_workingDirectory = workingDirectory;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private string GetConfiguration()
|
||||
{
|
||||
if (_configuration == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $"--configuration {_configuration}";
|
||||
}
|
||||
|
||||
private string GetFramework()
|
||||
{
|
||||
if (_framework == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $"--framework {_framework.GetShortFolderName()}";
|
||||
}
|
||||
|
||||
private string GetRuntime()
|
||||
{
|
||||
if (_runtime == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $"--runtime {_runtime}";
|
||||
}
|
||||
|
||||
private string GetNoDependencies()
|
||||
{
|
||||
if (!_noDependencies)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return "--no-dependencies";
|
||||
}
|
||||
|
||||
private string GetOutputPath()
|
||||
{
|
||||
if (_outputPath == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $"\"{_outputPath.FullName}\"";
|
||||
}
|
||||
|
||||
private string GetProjectFile()
|
||||
{
|
||||
if (_projectFile == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $"\"{_projectFile.FullName}\"";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +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 Microsoft.DotNet.Cli.Utils;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||
{
|
||||
public sealed class RestoreProjectJsonCommand : TestCommand
|
||||
{
|
||||
public RestoreProjectJsonCommand()
|
||||
: base(new RepoDirectoriesProvider().PjDotnet)
|
||||
{
|
||||
}
|
||||
|
||||
public override CommandResult Execute(string args="")
|
||||
{
|
||||
args = $"restore {args}";
|
||||
|
||||
return base.Execute(args);
|
||||
}
|
||||
|
||||
public override CommandResult ExecuteWithCapturedOutput(string args = "")
|
||||
{
|
||||
args = $"restore {args}";
|
||||
return base.ExecuteWithCapturedOutput(args);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,7 +20,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
private string _stage2Sdk;
|
||||
private string _stage2WithBackwardsCompatibleRuntimesDirectory;
|
||||
private string _testPackages;
|
||||
private string _pjDotnet;
|
||||
private string _testWorkingFolder;
|
||||
|
||||
public static string RepoRoot
|
||||
{
|
||||
|
@ -86,26 +86,27 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
public string Artifacts => _artifacts;
|
||||
public string BuiltDotnet => _builtDotnet;
|
||||
public string NugetPackages => _nugetPackages;
|
||||
public string PjDotnet => _pjDotnet;
|
||||
public string Stage2Sdk => _stage2Sdk;
|
||||
public string Stage2WithBackwardsCompatibleRuntimesDirectory => _stage2WithBackwardsCompatibleRuntimesDirectory;
|
||||
public string TestPackages => _testPackages;
|
||||
public string TestWorkingFolder => _testWorkingFolder;
|
||||
|
||||
public RepoDirectoriesProvider(
|
||||
string artifacts = null,
|
||||
string builtDotnet = null,
|
||||
string nugetPackages = null,
|
||||
string corehostPackages = null,
|
||||
string corehostDummyPackages = null,
|
||||
string pjDotnet = null)
|
||||
string corehostDummyPackages = null)
|
||||
{
|
||||
// Ideally this wouldn't be hardcoded, so that you could use stage n to build stage n + 1, and then use stage n + 1 to run tests
|
||||
int previousStage = 2;
|
||||
|
||||
_artifacts = artifacts ?? Path.Combine(RepoRoot,
|
||||
"out",
|
||||
"2", // Stage - ideally this would come from the "previous stage"
|
||||
previousStage.ToString(),
|
||||
BuildRid);
|
||||
_builtDotnet = builtDotnet ?? Path.Combine(_artifacts, "intermediate", "sharedFrameworkPublish");
|
||||
_nugetPackages = nugetPackages ?? Path.Combine(RepoRoot, ".nuget", "packages");
|
||||
_pjDotnet = pjDotnet ?? GetPjDotnetPath();
|
||||
_stage2Sdk = Directory
|
||||
.EnumerateDirectories(Path.Combine(_artifacts, "dotnet", "sdk"))
|
||||
.First(d => !d.Contains("NuGetFallbackFolder"));
|
||||
|
@ -118,14 +119,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
{
|
||||
throw new InvalidOperationException("TEST_PACKAGES environment variable not set");
|
||||
}
|
||||
}
|
||||
|
||||
private string GetPjDotnetPath()
|
||||
{
|
||||
return new DirectoryInfo(Path.Combine(RepoRoot, ".dotnet_stage0PJ"))
|
||||
.GetDirectories().First()
|
||||
.GetFiles("dotnet*").First()
|
||||
.FullName;
|
||||
_testWorkingFolder = Path.Combine(RepoRoot,
|
||||
"out",
|
||||
(previousStage + 1).ToString(),
|
||||
BuildRid,
|
||||
"test");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
s_testAssets = new TestAssets(
|
||||
new DirectoryInfo(assetsRoot),
|
||||
new FileInfo(new Muxer().MuxerPath),
|
||||
new FileInfo(new RepoDirectoriesProvider().PjDotnet));
|
||||
new RepoDirectoriesProvider().TestWorkingFolder);
|
||||
}
|
||||
|
||||
return s_testAssets;
|
||||
|
|
Loading…
Reference in a new issue