Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow toolset that tests run against to be controlled by command-line options #1674

Merged
merged 17 commits into from
Oct 26, 2017

Conversation

dsplaisted
Copy link
Member

  • Tests no longer need to be run from within an enlistment of dotnet/sdk. You should be able to build the tests, then copy the test folder (bin\Debug\Tests) and the TestAssets folder to another machine and run the tests there.
  • Command-line options can be used to specify what "toolset" to run against:
  -useFullMSBuild         : Use full framework (instead of .NET Core) version of MSBuild found in PATH
  -fullMSBuildPath <path> : Use full framework version of MSBuild in specified path
  -dotnetPath <path>      : Use specified path for dotnet host
  -sdkRepo <path>         : Use specified SDK repo for Microsoft.NET.SDK tasks / targets
  -sdkConfig <config>     : Use specified configuration for SDK repo
  -noRepoInference        : Don't automatically find SDK repo to use based on path to test binaries
  -help                   : Show help

@livarcocc
Copy link
Contributor

@tannergooding please review this change and validate that it does not break onboarding repotoolset.

@@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup Condition="'$(OutputType)' == 'Exe' ">
<Compile Include="$(MSBuildThisFileDirectory)TestProgram.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TestProgram.cs" Visible="false" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be 'Visible=false'

It is nice to be able to view this file and open it from within VS.


class Program
{
public static int Main(string[] args)
{
var newArgs = args.ToList();
newArgs.Insert(0, typeof(Program).Assembly.Location);
var newArgs = TestCommandLine.HandleCommandLine(args, out bool showHelp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Environment.GetCommandLineArgs() achieves the same thing and would work here.

Copy link
Member

@tannergooding tannergooding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I was about to do something similar to finish resolving the hard coded dependency that the tests had.

There will be some minimal conflicts, but they should be easy for me to resolve.


namespace Microsoft.NET.TestFramework
{
public class TestCommandLine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's name the file TestCommandLine.Default.cs instead of NOPCommandLine.cs

get
{
return Path.Combine(TestContext.Current.TestExecutionDirectory,
TestDirectoriesNamePrefix + NuGetSharedDirectoryNamePostfix);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunately pervasive in CLI/SDK code to do stuff like this in property getters, but we shouldn't produce fresh strings on every property access. If I review calling code that calls this more than once, I'm not going to imagine that to be problematic, because it looks like field access. Now, this is test code, so my care factor is not high, but it's something that I'm going to be pushing back on in product code.

throw new InvalidOperationException("Path to nuget.exe not set");
}

SdkCommandSpec ret = new SdkCommandSpec()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: var since type is obvious

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, can we name this spec instead of ret.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have ret all over the place. I won't comment on all of them, but I'd prefer readable names.


public string WorkingDirectory { get; set; }

string EscapeArgs()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private static


public ProcessStartInfo ToProcessStartInfo()
{
ProcessStartInfo ret = new ProcessStartInfo();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var info

public ICommand ToCommand()
{
var commandSpec = new CommandSpec(FileName, EscapeArgs(), CommandResolutionStrategy.Path);
ICommand ret = Command.Create(commandSpec);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

command

}
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra whitespace

@tannergooding
Copy link
Member

Is this currently blocked on anything? I need this to go in to finish up the repo-toolset changes.

@dsplaisted dsplaisted merged commit 3174e2a into dotnet:release/2.0.0 Oct 26, 2017
JL03-Yue pushed a commit that referenced this pull request Mar 19, 2024
…727.15 (#1674)

[main] Update dependencies from dotnet/arcade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants