Skip to content

Commit

Permalink
Fixtmppath (#1034)
Browse files Browse the repository at this point in the history
* Fixing

* Updated

* update runsettings

* Updating tests

* Ignoring tests that are not isolated

* Fixing tests.  Removing support for netcore2.1 as it interferes will tests, and is out of MS support
  • Loading branch information
OsirisTerje committed Nov 19, 2022
1 parent d0f38dc commit 0a03cfd
Show file tree
Hide file tree
Showing 24 changed files with 275 additions and 116 deletions.
2 changes: 1 addition & 1 deletion .runsettings
Expand Up @@ -2,7 +2,7 @@
<RunSettings>
<RunConfiguration>
<!-- 0 = As many processes as possible, limited by number of cores on machine, 1 = Sequential (1 process), 2-> Given number of processes up to limit by number of cores on machine-->
<MaxCpuCount>0</MaxCpuCount>
<MaxCpuCount>1</MaxCpuCount>

</RunConfiguration>

Expand Down
6 changes: 6 additions & 0 deletions NUnit3TestAdapter.sln
Expand Up @@ -61,6 +61,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
.github\workflows\NUnit3TestAdapter.Cake.CI.yml = .github\workflows\NUnit3TestAdapter.Cake.CI.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "netcoreapp3.1", "netcoreapp3.1", "{2F940513-5B8F-45A5-A188-7C5D03D1B50D}"
ProjectSection(SolutionItems) = preProject
nuget\netcoreapp3.1\NUnit3TestAdapter.props = nuget\netcoreapp3.1\NUnit3TestAdapter.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -100,6 +105,7 @@ Global
{A9584E41-6ECE-44B4-A504-41795A65DA5F} = {DE347D88-F6ED-4031-AFC2-318F63E39BC9}
{062B1763-73C8-4B5A-92DF-C66A36C43CE1} = {7CE30108-5D81-4850-BE6B-C8BCA35D3592}
{7D708804-B2F1-4A31-A9FB-85A0C7433200} = {062B1763-73C8-4B5A-92DF-C66A36C43CE1}
{2F940513-5B8F-45A5-A188-7C5D03D1B50D} = {DE347D88-F6ED-4031-AFC2-318F63E39BC9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8EF03474-188E-44A8-8C76-9FBCF9A382EC}
Expand Down
4 changes: 2 additions & 2 deletions build.cake
Expand Up @@ -12,7 +12,7 @@ var configuration = Argument("configuration", "Release");
// SET PACKAGE VERSION
//////////////////////////////////////////////////////////////////////

var version = "4.3.0";
var version = "4.3.1";
var modifier = "";


Expand Down Expand Up @@ -72,7 +72,7 @@ var BIN_DIR = PROJECT_DIR + "bin/" + configuration + "/";

var ADAPTER_PROJECT = SRC_DIR + "NUnitTestAdapter/NUnit.TestAdapter.csproj";

var NETCOREAPP_TFM = "netcoreapp2.1";
var NETCOREAPP_TFM = "netcoreapp3.1";

var ADAPTER_BIN_DIR_NET35 = SRC_DIR + $"NUnitTestAdapter/bin/{configuration}/net35/";
var ADAPTER_BIN_DIR_NETCOREAPP = SRC_DIR + $"NUnitTestAdapter/bin/{configuration}/{NETCOREAPP_TFM}/";
Expand Down
77 changes: 38 additions & 39 deletions nuget/NUnit3TestAdapter.nuspec
@@ -1,45 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>NUnit3TestAdapter</id>
<version>$version$</version>
<title>NUnit3 Test Adapter for Visual Studio and DotNet</title>
<authors>Charlie Poole, Terje Sandstrom</authors>
<license type="expression">MIT</license>
<projectUrl>https://docs.nunit.org/articles/vs-test-adapter/Index.html</projectUrl>
<repository type="git" url="https://github.com/nunit/nunit3-vs-adapter"/>
<iconUrl>https://cdn.rawgit.com/nunit/resources/master/images/icon/nunit_256.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>NUnit3 adapter for running tests in Visual Studio and DotNet. Works with NUnit 3.x, use the NUnit 2 adapter for 2.x tests.</summary>
<description>
The NUnit3 TestAdapter for Visual Studio, all versions from 2012 and onwards, and DotNet (incl. .Net core).
<metadata>
<id>NUnit3TestAdapter</id>
<version>$version$</version>
<title>NUnit3 Test Adapter for Visual Studio and DotNet</title>
<authors>Charlie Poole, Terje Sandstrom</authors>
<license type="expression">MIT</license>
<projectUrl>https://docs.nunit.org/articles/vs-test-adapter/Index.html</projectUrl>
<repository type="git" url="https://github.com/nunit/nunit3-vs-adapter"/>
<iconUrl>https://cdn.rawgit.com/nunit/resources/master/images/icon/nunit_256.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>NUnit3 adapter for running tests in Visual Studio and DotNet. Works with NUnit 3.x, use the NUnit 2 adapter for 2.x tests.</summary>
<description>
The NUnit3 TestAdapter for Visual Studio, all versions from 2012 and onwards, and DotNet (incl. .Net core).

Note that this package ONLY contains the adapter, not the NUnit framework.
For VS 2017 and forward, you should add this package to every test project in your solution. (Earlier versions only require a single adapter package per solution.)
</description>
<releaseNotes>See https://docs.nunit.org/articles/vs-test-adapter/Adapter-Release-Notes.html </releaseNotes>
<copyright>Copyright (c) 2011-2021 Charlie Poole, 2014-2022 Terje Sandstrom</copyright>
<language>en-US</language>
<tags>test visualstudio testadapter nunit nunit3 dotnet</tags>
Note that this package ONLY contains the adapter, not the NUnit framework.
For VS 2017 and forward, you should add this package to every test project in your solution. (Earlier versions only require a single adapter package per solution.)
</description>
<releaseNotes>See https://docs.nunit.org/articles/vs-test-adapter/Adapter-Release-Notes.html </releaseNotes>
<copyright>Copyright (c) 2011-2021 Charlie Poole, 2014-2022 Terje Sandstrom</copyright>
<language>en-US</language>
<tags>test visualstudio testadapter nunit nunit3 dotnet</tags>

<developmentDependency>false</developmentDependency>
</metadata>
<files>
<file src="build\net35\NUnit3.TestAdapter.dll" target="build\net35\NUnit3.TestAdapter.dll" />
<file src="build\net35\NUnit3.TestAdapter.pdb" target="build\net35\NUnit3.TestAdapter.pdb" />
<file src="build\net35\nunit.engine.dll" target="build\net35\nunit.engine.dll" />
<file src="build\net35\nunit.engine.api.dll" target="build\net35\nunit.engine.api.dll" />
<file src="build\net35\nunit.engine.core.dll" target="build\net35\nunit.engine.core.dll" />
<file src="build\net35\testcentric.engine.metadata.dll" target="build\net35\testcentric.engine.metadata.dll"/>
<file src="build\net35\NUnit3TestAdapter.props" target="build\net35\NUnit3TestAdapter.props" />
<developmentDependency>false</developmentDependency>
</metadata>
<files>
<file src="build\net35\NUnit3.TestAdapter.dll" target="build\net35\NUnit3.TestAdapter.dll" />
<file src="build\net35\NUnit3.TestAdapter.pdb" target="build\net35\NUnit3.TestAdapter.pdb" />
<file src="build\net35\nunit.engine.dll" target="build\net35\nunit.engine.dll" />
<file src="build\net35\nunit.engine.api.dll" target="build\net35\nunit.engine.api.dll" />
<file src="build\net35\nunit.engine.core.dll" target="build\net35\nunit.engine.core.dll" />
<file src="build\net35\testcentric.engine.metadata.dll" target="build\net35\testcentric.engine.metadata.dll"/>
<file src="build\net35\NUnit3TestAdapter.props" target="build\net35\NUnit3TestAdapter.props" />

<file src="build\netcoreapp2.1\NUnit3.TestAdapter.dll" target="build\netcoreapp2.1\NUnit3.TestAdapter.dll" />
<file src="build\netcoreapp2.1\NUnit3.TestAdapter.pdb" target="build\netcoreapp2.1\NUnit3.TestAdapter.pdb" />
<file src="build\netcoreapp2.1\nunit.engine.dll" target="build\netcoreapp2.1\nunit.engine.dll" />
<file src="build\netcoreapp2.1\nunit.engine.api.dll" target="build\netcoreapp2.1\nunit.engine.api.dll" />
<file src="build\netcoreapp2.1\nunit.engine.core.dll" target="build\netcoreapp2.1\nunit.engine.core.dll" />
<file src="build\netcoreapp2.1\testcentric.engine.metadata.dll" target="build\netcoreapp2.1\testcentric.engine.metadata.dll"/>
<file src="build\netcoreapp2.1\NUnit3TestAdapter.props" target="build\netcoreapp2.1\NUnit3TestAdapter.props" />

</files>
<file src="build\netcoreapp3.1\NUnit3.TestAdapter.dll" target="build\netcoreapp3.1\NUnit3.TestAdapter.dll" />
<file src="build\netcoreapp3.1\NUnit3.TestAdapter.pdb" target="build\netcoreapp3.1\NUnit3.TestAdapter.pdb" />
<file src="build\netcoreapp3.1\nunit.engine.dll" target="build\netcoreapp3.1\nunit.engine.dll" />
<file src="build\netcoreapp3.1\nunit.engine.api.dll" target="build\netcoreapp3.1\nunit.engine.api.dll" />
<file src="build\netcoreapp3.1\nunit.engine.core.dll" target="build\netcoreapp3.1\nunit.engine.core.dll" />
<file src="build\netcoreapp3.1\testcentric.engine.metadata.dll" target="build\netcoreapp3.1\testcentric.engine.metadata.dll"/>
<file src="build\netcoreapp3.1\NUnit3TestAdapter.props" target="build\netcoreapp3.1\NUnit3TestAdapter.props" />
</files>
</package>
35 changes: 35 additions & 0 deletions nuget/netcoreapp3.1/NUnit3TestAdapter.props
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)NUnit3.TestAdapter.dll">
<Link>NUnit3.TestAdapter.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</None>
<None Include="$(MSBuildThisFileDirectory)NUnit3.TestAdapter.pdb" Condition="Exists('$(MSBuildThisFileDirectory)NUnit3.TestAdapter.pdb')">
<Link>NUnit3.TestAdapter.pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</None>
<None Include="$(MSBuildThisFileDirectory)nunit.engine.dll">
<Link>nunit.engine.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</None>
<None Include="$(MSBuildThisFileDirectory)nunit.engine.api.dll">
<Link>nunit.engine.api.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</None>
<None Include="$(MSBuildThisFileDirectory)nunit.engine.core.dll">
<Link>nunit.engine.core.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</None>
<None Include="$(MSBuildThisFileDirectory)testcentric.engine.metadata.dll">
<Link>testcentric.engine.metadata.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</None>
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/NUnit.TestAdapter.Tests.Acceptance/AcceptanceTests.cs
Expand Up @@ -32,12 +32,12 @@ public abstract class AcceptanceTests
public static IEnumerable<string> TargetFrameworks => new[]
{
LowestNetfxTarget,
Frameworks.NetCoreApp21
Frameworks.NetCoreApp31
};

public static IEnumerable<string> DotNetCliTargetFrameworks => new[]
{
Frameworks.NetCoreApp21,
// Frameworks.NetCoreApp21, // Doesnt seem to be supported by VS 2022 anymore
Frameworks.NetCoreApp31,
Frameworks.Net50,
Frameworks.Net60,
Expand Down
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="nunit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="NUnit.Analyzers" Version="3.5.0" />
</ItemGroup>

Expand Down
Expand Up @@ -83,8 +83,9 @@ public class Case

[Test, Platform("Win")]
[TestCase("net48")] // test code requires ValueTuple support, so can't got to net35
[TestCase("netcoreapp2.1")]
[TestCase("netcoreapp3.1")]
[TestCase("net5.0")]
[TestCase("net6.0")]
public static void Single_target_csproj(string targetFramework)
{
var workspace = CreateWorkspace()
Expand Down
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>NUnit.VisualStudio.TestAdapter.ExternalTests</AssemblyName>
<RootNamespace>NUnit.VisualStudio.TestAdapter.Tests</RootNamespace>
<TargetFrameworks>net45;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net45;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
81 changes: 65 additions & 16 deletions src/NUnitTestAdapter/AdapterSettings.cs
Expand Up @@ -29,6 +29,8 @@
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;

using NUnit.Engine;

namespace NUnit.VisualStudio.TestAdapter
{
public interface IAdapterSettings
Expand All @@ -40,7 +42,7 @@ public interface IAdapterSettings
string TestAdapterPaths { get; }
bool CollectSourceInformation { get; }
IDictionary<string, string> TestProperties { get; }
string InternalTraceLevel { get; }
InternalTraceLevel InternalTraceLevelEnum { get; }
string WorkDirectory { get; }
string Where { get; }
int DefaultTimeout { get; }
Expand Down Expand Up @@ -115,7 +117,7 @@ public interface IAdapterSettings
bool IncludeStackTraceForSuites { get; }


void Load(IDiscoveryContext context);
void Load(IDiscoveryContext context, TestLogger testLogger = null);
void Load(string settingsXml);
void SaveRandomSeed(string dirname);
void RestoreRandomSeed(string dirname);
Expand All @@ -132,6 +134,7 @@ public interface IAdapterSettings
ExplicitModeEnum ExplicitMode { get; }
bool SkipExecutionWhenNoTests { get; }
string TestOutputFolder { get; }
string SetTestOutputFolder(string workDirectory);
}

public enum VsTestCategoryType
Expand Down Expand Up @@ -210,7 +213,11 @@ public AdapterSettings(ITestLogger logger)
#region Properties - NUnit Specific

public string InternalTraceLevel { get; private set; }
public InternalTraceLevel InternalTraceLevelEnum { get; private set; }

/// <summary>
/// Is null if not set in runsettings.
/// </summary>
public string WorkDirectory { get; private set; }
public string Where { get; private set; }
public string TestOutputXml { get; private set; }
Expand Down Expand Up @@ -303,8 +310,14 @@ public AdapterSettings(ITestLogger logger)

#region Public Methods

public void Load(IDiscoveryContext context)
/// <summary>
/// Initialized by the Load method.
/// </summary>
private TestLogger testLog;

public void Load(IDiscoveryContext context, TestLogger testLogger)
{
testLog = testLogger;
if (context == null)
throw new ArgumentNullException(nameof(context), "Load called with null context");

Expand Down Expand Up @@ -338,12 +351,9 @@ public void Load(string settingsXml)
UseVsKeepEngineRunning = GetInnerTextAsBool(nunitNode, nameof(UseVsKeepEngineRunning), false);
BasePath = GetInnerTextWithLog(nunitNode, nameof(BasePath));
PrivateBinPath = GetInnerTextWithLog(nunitNode, nameof(PrivateBinPath));
TestOutputXml = GetInnerTextWithLog(nunitNode, nameof(TestOutputXml));
OutputXmlFolderMode = MapEnum(GetInnerText(nunitNode, nameof(OutputXmlFolderMode), Verbosity > 0), OutputXmlFolderMode.RelativeToWorkFolder);
ParseOutputXml(nunitNode);
NewOutputXmlFileForEachRun = GetInnerTextAsBool(nunitNode, nameof(NewOutputXmlFileForEachRun), false);

SetTestOutputFolder();

RandomSeed = GetInnerTextAsNullableInt(nunitNode, nameof(RandomSeed));
RandomSeedSpecified = RandomSeed.HasValue;
if (!RandomSeedSpecified)
Expand Down Expand Up @@ -418,24 +428,44 @@ public void Load(string settingsXml)
UpdateNumberOfTestWorkers();
}

private void SetTestOutputFolder()
private void ParseOutputXml(XmlNode nunitNode)
{
if (!UseTestOutputXml)
TestOutputXml = GetInnerTextWithLog(nunitNode, nameof(TestOutputXml));
if (Path.IsPathRooted(TestOutputXml))
{
OutputXmlFolderMode = OutputXmlFolderMode.AsSpecified;
return;
}
var outputMode = GetInnerText(nunitNode, nameof(OutputXmlFolderMode), Verbosity > 0);

if (string.IsNullOrEmpty(WorkDirectory) && string.IsNullOrEmpty(outputMode))
{
OutputXmlFolderMode = string.IsNullOrEmpty(TestOutputXml) ? OutputXmlFolderMode.UseResultDirectory : OutputXmlFolderMode.RelativeToResultDirectory;
}

OutputXmlFolderMode = MapEnum(outputMode, OutputXmlFolderMode.RelativeToWorkFolder);
}

public string SetTestOutputFolder(string workDirectory)
{
if (!UseTestOutputXml)
return "";
switch (OutputXmlFolderMode)
{
case OutputXmlFolderMode.UseResultDirectory:
TestOutputFolder = ResultsDirectory;
return;
return TestOutputFolder;
case OutputXmlFolderMode.RelativeToResultDirectory:
TestOutputFolder = Path.Combine(ResultsDirectory, TestOutputXml);
return;
return TestOutputFolder;
case OutputXmlFolderMode.RelativeToWorkFolder:
TestOutputFolder = Path.Combine(WorkDirectory, TestOutputXml);
return;
TestOutputFolder = Path.Combine(workDirectory, TestOutputXml);
return TestOutputFolder;
case OutputXmlFolderMode.AsSpecified:
TestOutputFolder = TestOutputXml;
return TestOutputFolder;
default:
return;
return "";
}
}

Expand All @@ -445,13 +475,32 @@ private void ExtractNUnitDiagnosticSettings(XmlNode nunitNode)
DumpXmlTestResults = GetInnerTextAsBool(nunitNode, nameof(DumpXmlTestResults), false);
DumpVsInput = GetInnerTextAsBool(nunitNode, nameof(DumpVsInput), false);
FreakMode = GetInnerTextAsBool(nunitNode, nameof(FreakMode), false);
InternalTraceLevel = GetInnerTextWithLog(nunitNode, nameof(InternalTraceLevel), "Off", "Error", "Warning",
"Info", "Verbose", "Debug");
InternalTraceLevel = GetInnerTextWithLog(nunitNode, nameof(InternalTraceLevel), "Off", "Error", "Warning", "Info", "Verbose", "Debug");
InternalTraceLevelEnum = ParseInternalTraceLevel(InternalTraceLevel);
Debug = GetInnerTextAsBool(nunitNode, nameof(Debug), false);
DebugExecution = Debug || GetInnerTextAsBool(nunitNode, nameof(DebugExecution), false);
DebugDiscovery = Debug || GetInnerTextAsBool(nunitNode, nameof(DebugDiscovery), false);
}

private InternalTraceLevel ParseInternalTraceLevel(string s)
{
if (s == null)
{
return Engine.InternalTraceLevel.Off;
}

try
{
var internalTrace = (InternalTraceLevel)Enum.Parse(typeof(InternalTraceLevel), s);
return internalTrace;
}
catch
{
testLog.Warning($"InternalTraceLevel is non-valid: {s}, see https://docs.nunit.org/articles/vs-test-adapter/Tips-And-Tricks.html");
return Engine.InternalTraceLevel.Off;
}
}

private void UpdateTestProperties(XmlDocument doc)
{
TestProperties = new Dictionary<string, string>();
Expand Down
4 changes: 2 additions & 2 deletions src/NUnitTestAdapter/NUnit.TestAdapter.csproj
Expand Up @@ -4,9 +4,9 @@
<AssemblyName>NUnit3.TestAdapter</AssemblyName>
<!--<AssemblyName>NUnit3.TestAdapterDebug</AssemblyName>-->
<RootNamespace>NUnit.VisualStudio.TestAdapter</RootNamespace>
<!--<TargetFramework>netcoreapp2.1</TargetFramework>-->
<!--<TargetFramework>netcoreapp3.1</TargetFramework>-->
<!-- For testing and debugging-->
<TargetFrameworks>net35;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net35;netcoreapp3.1</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<SourceLinkOriginUrl>https://github.com/nunit/nunit3-vs-adapter</SourceLinkOriginUrl>
<SourceLinkCreate>true</SourceLinkCreate>
Expand Down

0 comments on commit 0a03cfd

Please sign in to comment.