Use a shorter path for test working directories, get rid of Stage 0 project.json based CLI
(cherry picked from commit 4c3b13e4a8
)
This commit is contained in:
parent
dfe1f69f97
commit
9f3bbc40a2
8 changed files with 32 additions and 313 deletions
|
@ -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
|
||||
{
|
||||
|
@ -81,26 +81,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"));
|
||||
|
@ -113,14 +114,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…
Add table
Add a link
Reference in a new issue