Fixing dotnet-test.Tests to use a portable test app - ProjectWithTests.
The ProjectWithTests needed to be moved outside of TestAssets\TestProjects because it can't be restored --infer-runtimes and it has to be built with netcoreapp1.0.
This commit is contained in:
		
					parent
					
						
							
								8a9068efbf
							
						
					
				
			
			
				commit
				
					
						7d6d74bba2
					
				
			
		
					 5 changed files with 36 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -1,15 +1,19 @@
 | 
			
		|||
{
 | 
			
		||||
  "version": "1.0.0-*",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "NETStandard.Library": "1.5.0-rc2-24008",
 | 
			
		||||
    "Microsoft.NETCore.App": {
 | 
			
		||||
      "type": "platform",
 | 
			
		||||
      "version": "1.0.0-rc2-*"
 | 
			
		||||
    },
 | 
			
		||||
    "System.Linq.Expressions": "4.0.11-rc2-24008",
 | 
			
		||||
    "System.Runtime.Serialization.Primitives": "4.1.1-rc2-24008",
 | 
			
		||||
    "xunit": "2.1.0",
 | 
			
		||||
    "dotnet-test-xunit": "1.0.0-dev-128011-22"
 | 
			
		||||
    "dotnet-test-xunit": "1.0.0-dev-140469-38"
 | 
			
		||||
  },
 | 
			
		||||
  "frameworks": {
 | 
			
		||||
    "netstandardapp1.5": {
 | 
			
		||||
    "netcoreapp1.0": {
 | 
			
		||||
      "imports": [
 | 
			
		||||
        "netstandardapp1.5",
 | 
			
		||||
        "dnxcore50",
 | 
			
		||||
        "portable-net45+win8"
 | 
			
		||||
      ]
 | 
			
		||||
| 
						 | 
				
			
			@ -93,7 +93,17 @@ namespace Microsoft.DotNet.Cli.Build
 | 
			
		|||
                "--fallbacksource", Dirs.TestPackages,
 | 
			
		||||
                "--fallbacksource", Dirs.Corehost)
 | 
			
		||||
                .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects"))
 | 
			
		||||
                .Execute().EnsureSuccessful();
 | 
			
		||||
                .Execute()
 | 
			
		||||
                .EnsureSuccessful();
 | 
			
		||||
 | 
			
		||||
            // The 'ProjectWithTests' is a portable test app. Cannot call --infer-runtimes on it, since on win x64 machines,
 | 
			
		||||
            // the x86 runtime is being inferred, and there are no x86 DotNetHost packages
 | 
			
		||||
            dotnet.Restore(
 | 
			
		||||
                "--verbosity", "verbose",
 | 
			
		||||
                "--fallbacksource", Dirs.Corehost)
 | 
			
		||||
                .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectWithTests"))
 | 
			
		||||
                .Execute()
 | 
			
		||||
                .EnsureSuccessful();
 | 
			
		||||
 | 
			
		||||
            // The 'ProjectModelServer' directory contains intentionally-unresolved dependencies, so don't check for success. Also, suppress the output
 | 
			
		||||
            dotnet.Restore(
 | 
			
		||||
| 
						 | 
				
			
			@ -248,6 +258,14 @@ namespace Microsoft.DotNet.Cli.Build
 | 
			
		|||
                    .EnsureSuccessful();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // build ProjectWithTests, which is outside of TestProjects and targets netcoreapp
 | 
			
		||||
            string projectWithTests = Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectWithTests");
 | 
			
		||||
            c.Info($"Building: {projectWithTests}");
 | 
			
		||||
            dotnet.Build("--framework", "netcoreapp1.0")
 | 
			
		||||
                .WorkingDirectory(projectWithTests)
 | 
			
		||||
                .Execute()
 | 
			
		||||
                .EnsureSuccessful();
 | 
			
		||||
 | 
			
		||||
            return c.Success();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,6 +4,7 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using Microsoft.DotNet.ProjectModel;
 | 
			
		||||
using Microsoft.DotNet.TestFramework;
 | 
			
		||||
using Microsoft.Extensions.PlatformAbstractions;
 | 
			
		||||
using Xunit;
 | 
			
		||||
using Microsoft.DotNet.Tools.Test.Utilities;
 | 
			
		||||
| 
						 | 
				
			
			@ -18,8 +19,9 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
 | 
			
		|||
 | 
			
		||||
        public GivenThatWeWantToRunTestsInTheConsole()
 | 
			
		||||
        {
 | 
			
		||||
            var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets"));
 | 
			
		||||
            var testInstance =
 | 
			
		||||
                TestAssetsManager.CreateTestInstance("ProjectWithTests", identifier: "ConsoleTests").WithLockFiles();
 | 
			
		||||
                testAssetManager.CreateTestInstance("ProjectWithTests", identifier: "ConsoleTests").WithLockFiles();
 | 
			
		||||
 | 
			
		||||
            _projectFilePath = Path.Combine(testInstance.TestRoot, "project.json");
 | 
			
		||||
            var contexts = ProjectContext.CreateContextForEachFramework(
 | 
			
		||||
| 
						 | 
				
			
			@ -27,8 +29,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
 | 
			
		|||
                null,
 | 
			
		||||
                PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers());
 | 
			
		||||
 | 
			
		||||
            var runtime = contexts.FirstOrDefault(c => !string.IsNullOrEmpty(c.RuntimeIdentifier))?.RuntimeIdentifier;
 | 
			
		||||
            _defaultOutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", DefaultFramework, runtime);
 | 
			
		||||
            _defaultOutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "netcoreapp1.0");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //ISSUE https://github.com/dotnet/cli/issues/1935
 | 
			
		||||
| 
						 | 
				
			
			@ -55,7 +56,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
 | 
			
		|||
        {
 | 
			
		||||
            var testCommand = new DotnetTestCommand();
 | 
			
		||||
            var result = testCommand.Execute(
 | 
			
		||||
                $"{_projectFilePath} -o {Path.Combine(AppContext.BaseDirectory, "output")} -f netstandardapp1.5");
 | 
			
		||||
                $"{_projectFilePath} -o {Path.Combine(AppContext.BaseDirectory, "output")} -f netcoreapp1.0");
 | 
			
		||||
            result.Should().Pass();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,7 @@
 | 
			
		|||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 | 
			
		||||
 | 
			
		||||
using Microsoft.DotNet.ProjectModel;
 | 
			
		||||
using Microsoft.DotNet.TestFramework;
 | 
			
		||||
using Microsoft.DotNet.Tools.Test.Utilities;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using FluentAssertions;
 | 
			
		||||
| 
						 | 
				
			
			@ -18,15 +19,16 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
 | 
			
		|||
 | 
			
		||||
        public GivenThatWeWantToUseDotnetTestE2EInDesignTime()
 | 
			
		||||
        {
 | 
			
		||||
            var testInstance = TestAssetsManager.CreateTestInstance("ProjectWithTests").WithLockFiles();
 | 
			
		||||
            var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets"));
 | 
			
		||||
            var testInstance = testAssetManager.CreateTestInstance("ProjectWithTests").WithLockFiles();
 | 
			
		||||
 | 
			
		||||
            _projectFilePath = Path.Combine(testInstance.TestRoot, "project.json");
 | 
			
		||||
            var contexts = ProjectContext.CreateContextForEachFramework(
 | 
			
		||||
                _projectFilePath,
 | 
			
		||||
                null,
 | 
			
		||||
                PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers());
 | 
			
		||||
            var runtime = contexts.FirstOrDefault(c => !string.IsNullOrEmpty(c.RuntimeIdentifier))?.RuntimeIdentifier;
 | 
			
		||||
            _outputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", DefaultFramework, runtime);
 | 
			
		||||
 | 
			
		||||
            _outputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "netcoreapp1.0");
 | 
			
		||||
            var buildCommand = new BuildCommand(_projectFilePath);
 | 
			
		||||
            var result = buildCommand.Execute();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue