summaryrefslogtreecommitdiff
path: root/tests/src
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2019-05-21 13:28:49 -0700
committerGitHub <noreply@github.com>2019-05-21 13:28:49 -0700
commitc03f31fbc4105cbea4053409f91bc25040093d20 (patch)
tree325a7a53176152636e9f8378cb72adf8ca4b4972 /tests/src
parent5a44c6f3ce7629a8cd55b56a2f3d8c66c6e87b34 (diff)
downloadcoreclr-c03f31fbc4105cbea4053409f91bc25040093d20.tar.gz
coreclr-c03f31fbc4105cbea4053409f91bc25040093d20.tar.bz2
coreclr-c03f31fbc4105cbea4053409f91bc25040093d20.zip
Delete infrastructure files that are no longer used (#24684)
* Delete Jenkins scripts * Delete support files for the old CoreFX test infrastructure * Delete CoreFX test file setup utility
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/Common/CoreFX/TestFileSetup/CoreFX.TestUtils.TestFileSetup.csproj36
-rw-r--r--tests/src/Common/CoreFX/TestFileSetup/Helpers/TestFileHelper.cs326
-rw-r--r--tests/src/Common/CoreFX/TestFileSetup/Helpers/TestRunHelper.cs158
-rw-r--r--tests/src/Common/CoreFX/TestFileSetup/Program.cs174
-rw-r--r--tests/src/Common/CoreFX/TestFileSetup/RSPGenerator.cs83
-rw-r--r--tests/src/Common/CoreFX/TestFileSetup/XUnit/XUnitTestAssembly.cs63
6 files changed, 0 insertions, 840 deletions
diff --git a/tests/src/Common/CoreFX/TestFileSetup/CoreFX.TestUtils.TestFileSetup.csproj b/tests/src/Common/CoreFX/TestFileSetup/CoreFX.TestUtils.TestFileSetup.csproj
deleted file mode 100644
index 751b3ab8d3..0000000000
--- a/tests/src/Common/CoreFX/TestFileSetup/CoreFX.TestUtils.TestFileSetup.csproj
+++ /dev/null
@@ -1,36 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">
- <Import Project="..\..\..\..\..\dependencies.props" />
- <PropertyGroup>
- <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
- <SystemCommandLineVersion>0.1.0-e160909-1</SystemCommandLineVersion>
- <NewtonsoftJsonVersion>11.0.2</NewtonsoftJsonVersion>
- <NewtonsoftJsonSchemaVersion>3.0.10</NewtonsoftJsonSchemaVersion>
- <XunitPackageVersion>2.3.0-beta1-build3642</XunitPackageVersion>
- <!-- Due to an API surface mismatch, if the xunit.netcore executable attempts to run the wrong version of the
- runner utility, running the tests wil break, so separate both into different version definitions -->
- <XunitRunnerUtilityVersion>2.2.0-beta2-build3300</XunitRunnerUtilityVersion>
- <XunitAbstractionsVersion>2.0.1</XunitAbstractionsVersion>
- <XunitNetcoreExtensionsVersion>2.1.0-preview2-02516-02</XunitNetcoreExtensionsVersion>
- <CoreFxTestUtilitiesVersion>4.5.0-preview2-26219-0</CoreFxTestUtilitiesVersion>
- <RestoreSources>$(RestoreSources);https://dotnet.myget.org/F/dotnet-corefxlab/api/v3/index.json</RestoreSources>
- </PropertyGroup>
-
- <PropertyGroup>
- <TargetFramework>netcoreapp2.0</TargetFramework>
- <OutputType>Exe</OutputType>
- <NETCoreAppMaximumVersion>99.9</NETCoreAppMaximumVersion>
- </PropertyGroup>
-
- <ItemGroup>
- <PackageReference Include="Newtonsoft.Json">
- <Version>$(NewtonsoftJsonVersion)</Version>
- </PackageReference>
- <PackageReference Include="Newtonsoft.Json.Schema">
- <Version>$(NewtonsoftJsonSchemaVersion)</Version>
- </PackageReference>
- <!-- TODO Remove this reference - System.CommandLine is now archived and not under active development -->
- <PackageReference Include="System.CommandLine">
- <Version>$(SystemCommandLineVersion)</Version>
- </PackageReference>
- </ItemGroup>
-</Project>
diff --git a/tests/src/Common/CoreFX/TestFileSetup/Helpers/TestFileHelper.cs b/tests/src/Common/CoreFX/TestFileSetup/Helpers/TestFileHelper.cs
deleted file mode 100644
index e6e2c4ed6c..0000000000
--- a/tests/src/Common/CoreFX/TestFileSetup/Helpers/TestFileHelper.cs
+++ /dev/null
@@ -1,326 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Collections.Generic;
-using System.CommandLine;
-using System.Diagnostics;
-using System.IO;
-using System.IO.Compression;
-using System.Net.Http;
-using System.Text;
-using System.Threading.Tasks;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Schema;
-using Newtonsoft.Json.Schema.Generation;
-
-namespace CoreFX.TestUtils.TestFileSetup.Helpers
-{
- /// <summary>
- /// Defines the set of flags that represent exit codes
- /// </summary>
- [Flags]
- public enum ExitCode : int
- {
- Success = 0,
- TestFailure = 1,
- HttpError = 2,
- IOError = 3,
- JsonSchemaValidationError = 4,
- UnknownError = 10
-
- }
-
- /// <summary>
- /// This helper class is used to fetch CoreFX tests from a specified URL, unarchive them and create a flat directory structure
- /// through which to iterate.
- /// </summary>
- public class TestFileHelper
- {
- private HttpClient httpClient;
- public HttpClient HttpClient
- {
- get
- {
- if (httpClient == null)
- {
- httpClient = new HttpClient();
- }
- return httpClient;
- }
- set{ httpClient = value; }
- }
-
- private HashSet<string> disabledTests;
-
- /// <summary>
- /// Default constructor - initialize list of disabled tests
- /// </summary>
- public TestFileHelper() {
- disabledTests = new HashSet<string>();
- }
-
- /// <summary>
- /// Deserialize a list of JSON objects defining test assemblies
- /// </summary>
- /// <param name="testDefinitionFilePath">The path on disk to the test list. The test list must conform to a schema generated from XUnitTestAssembly</param>
- /// <returns></returns>
- public Dictionary<string, XUnitTestAssembly> DeserializeTestJson(string testDefinitionFilePath)
- {
- JSchemaGenerator jsonGenerator = new JSchemaGenerator();
-
- // Generate a JSON schema from the XUnitTestAssembly class against which to validate the test list
- JSchema testDefinitionSchema = jsonGenerator.Generate(typeof(IList<XUnitTestAssembly>));
- IList<XUnitTestAssembly> testAssemblies = new List<XUnitTestAssembly>();
-
- IList<string> validationMessages = new List<string>();
-
- using (var sr = new StreamReader(testDefinitionFilePath))
- using (var jsonReader = new JsonTextReader(sr))
- using (var jsonValidationReader = new JSchemaValidatingReader(jsonReader))
- {
- // Create schema validator
- jsonValidationReader.Schema = testDefinitionSchema;
- jsonValidationReader.ValidationEventHandler += (o, a) => validationMessages.Add(a.Message);
-
- // Deserialize json test assembly definitions
- JsonSerializer serializer = new JsonSerializer();
- try
- {
- testAssemblies = serializer.Deserialize<List<XUnitTestAssembly>>(jsonValidationReader);
- }
- catch (JsonSerializationException ex)
- {
- // Invalid definition
- throw new AggregateException(ex);
- }
- }
-
- if (validationMessages.Count != 0)
- {
- StringBuilder aggregateExceptionMessage = new StringBuilder();
- foreach (string validationMessage in validationMessages)
- {
- aggregateExceptionMessage.Append("JSON Validation Error: ");
- aggregateExceptionMessage.Append(validationMessage);
- aggregateExceptionMessage.AppendLine();
- }
-
- throw new AggregateException(new JSchemaValidationException(aggregateExceptionMessage.ToString()));
-
- }
- // Generate a map of test assembly names to their object representations - this is used to download and match them to their on-disk representations
- var nameToTestAssemblyDef = new Dictionary<string, XUnitTestAssembly>();
-
- // Map test names to their definitions
- foreach (XUnitTestAssembly assembly in testAssemblies)
- {
- // Filter disabled tests
- if(assembly.IsEnabled)
- nameToTestAssemblyDef.Add(assembly.Name, assembly);
- else
- disabledTests.Add(assembly.Name);
- }
-
- return nameToTestAssemblyDef;
- }
-
- /// <summary>
- /// Layout tests on disk. This method sets up every downloaded test as it would appear after running build-test.[cmd/sh] in CoreFX
- /// </summary>
- /// <param name="jsonUrl">URL to a test list - we expect a test list, which conforms to the Helix layout</param>
- /// <param name="destinationDirectory">Directory to which the tests are downloaded</param>
- /// <param name="testDefinitions">The mapping of tests parsed from a test definition list to their names</param>
- /// <param name="runAllTests">Optional argument, which denotes whether all tests available in the test list downloaded from jsonUrl should be run</param>
- /// <returns></returns>
- public async Task SetupTests(string jsonUrl, string destinationDirectory, Dictionary<string, XUnitTestAssembly> testDefinitions = null, bool runAllTests = false)
- {
- Debug.Assert(Directory.Exists(destinationDirectory));
- // testDefinitions should not be empty unless we're running all tests with no exclusions
- Debug.Assert(runAllTests || testDefinitions != null);
-
- // Download archives to a temporary directory
- string tempDirPath = Path.Combine(destinationDirectory, "temp");
- if (!Directory.Exists(tempDirPath))
- {
- Directory.CreateDirectory(tempDirPath);
- }
- // Map test names to their URLs, specified by the test list found at jsonUrl
- Dictionary<string, XUnitTestAssembly> testPayloads = await GetTestUrls(jsonUrl, testDefinitions, runAllTests);
-
- // If none were found or the testList did not have the expected format - return
- if (testPayloads == null)
- {
- return;
- }
-
- // Download and unzip tests
- await GetTestArchives(testPayloads, tempDirPath);
- ExpandArchivesInDirectory(tempDirPath, destinationDirectory);
-
- // Generate response file for each tests
- RSPGenerator rspGenerator = new RSPGenerator();
- foreach (XUnitTestAssembly assembly in testDefinitions.Values)
- {
- rspGenerator.GenerateRSPFile(assembly, Path.Combine(destinationDirectory, assembly.Name));
- }
-
- Directory.Delete(tempDirPath);
- }
-
- /// <summary>
- /// Maps test names to their respective URLs as found in the test list found at the specified URL
- /// </summary>
- /// <param name="jsonUrl">URL to a test list - we expect a test list, which conforms to the Helix layout</param>
- /// <param name="testDefinitions">The mapping of tests parsed from a test definition list to their names</param>
- /// <param name="runAllTests">Optional argument, which denotes whether all tests available in the test list downloaded from jsonUrl should be run</param>
- /// <returns></returns>
- public async Task<Dictionary<string, XUnitTestAssembly>> GetTestUrls(string jsonUrl, Dictionary<string, XUnitTestAssembly> testDefinitions = null, bool runAllTests = false)
- {
- // testDefinitions should not be empty unless we're running all tests with no exclusions
- Debug.Assert(runAllTests || testDefinitions != null);
- // Set up the json stream reader
- using (var responseStream = await HttpClient.GetStreamAsync(jsonUrl))
- using (var streamReader = new StreamReader(responseStream))
- using (var jsonReader = new JsonTextReader(streamReader))
- {
- // Manual parsing - we only need to key-value pairs from each object and this avoids deserializing all of the work items into objects
- string markedTestName = string.Empty;
- string currentPropertyName = string.Empty;
-
- // The expected layout is produced by regular Helix runs - this allows us to parse and run tests from any Helix test list without special considerations
- // The expected fields are
- // { "WorkItemId": "<Fully Qualified Test Name>" , "PayloadUri":"<Url Of Test>" }
-
- while (jsonReader.Read())
- {
- if (jsonReader.Value != null)
- {
- switch (jsonReader.TokenType)
- {
- case JsonToken.PropertyName:
- currentPropertyName = jsonReader.Value.ToString();
- break;
- case JsonToken.String:
- // Test Name Value
- if (currentPropertyName.Equals("WorkItemId"))
- {
- string currentTestName = jsonReader.Value.ToString();
-
- // If the test has been marked as disabled in the test list - ignore it
- if ((runAllTests || testDefinitions.ContainsKey(currentTestName)) && !disabledTests.Contains(currentTestName))
- {
- markedTestName = currentTestName;
- }
- }
- // Test URL value
- else if (currentPropertyName.Equals("PayloadUri") && markedTestName != string.Empty)
- {
- if (!testDefinitions.ContainsKey(markedTestName))
- {
- testDefinitions[markedTestName] = new XUnitTestAssembly() { Name = markedTestName };
- }
- testDefinitions[markedTestName].Url = jsonReader.Value.ToString();
- markedTestName = string.Empty;
- }
- break;
- }
- }
- }
-
- }
- return testDefinitions;
- }
-
- /// <summary>
- /// Download each test from its specified URL
- /// </summary>
- /// <param name="testPayloads">The mapping of tests parsed from a test definition list to their names. The test definitions are populated with test URLs</param>
- /// <param name="downloadDir">Directory to which to download tests</param>
- /// <returns></returns>
- public async Task GetTestArchives(Dictionary<string, XUnitTestAssembly> testPayloads, string downloadDir)
- {
- foreach (string testName in testPayloads.Keys)
- {
- string payloadUri = testPayloads[testName].Url;
-
- // Check URL for validity
- if (!Uri.IsWellFormedUriString(payloadUri, UriKind.Absolute))
- continue;
- Console.WriteLine("Downloading " + testName + " from " + payloadUri);
- // Download tests from specified URL
- using (var response = await HttpClient.GetStreamAsync(payloadUri))
- {
- if (response.CanRead)
- {
- // Create the test setup directory if it doesn't exist
- if (!Directory.Exists(downloadDir))
- {
- Directory.CreateDirectory(downloadDir);
- }
-
- // CoreFX test archives are output as .zip regardless of platform
- string archivePath = Path.Combine(downloadDir, testName + ".zip");
-
- // Copy to a temp folder
- using (FileStream file = new FileStream(archivePath, FileMode.Create))
- {
- await response.CopyToAsync(file);
- }
-
- }
- }
- }
- }
-
- /// <summary>
- /// Expand Archives
- /// </summary>
- /// <param name="archiveDirectory">Directory containing archives</param>
- /// <param name="destinationDirectory">Directory to which to unpack archives</param>
- /// <param name="cleanup">Optional parameter stating, whether archives should be deleted once downloaded</param>
- public void ExpandArchivesInDirectory(string archiveDirectory, string destinationDirectory, bool cleanup = true)
- {
- Debug.Assert(Directory.Exists(archiveDirectory));
- Debug.Assert(Directory.Exists(destinationDirectory));
-
- // Get all archives in the directory
- string[] archives = Directory.GetFiles(archiveDirectory, "*.zip", SearchOption.TopDirectoryOnly);
-
- foreach (string archivePath in archives)
- {
- string destinationDirName = Path.Combine(destinationDirectory, Path.GetFileNameWithoutExtension(archivePath));
-
- ZipFile.ExtractToDirectory(archivePath, destinationDirName);
-
- // Delete archives if cleanup was
- if (cleanup)
- {
- File.Delete(archivePath);
- }
- }
- }
-
- /// <summary>
- /// Cleans build directory
- /// </summary>
- /// <param name="directoryToClean">Directory the contents of which to delete.</param>
- public void CleanBuild(string directoryToClean)
- {
- Debug.Assert(Directory.Exists(directoryToClean));
- DirectoryInfo dirInfo = new DirectoryInfo(directoryToClean);
-
- foreach (FileInfo file in dirInfo.EnumerateFiles())
- {
- file.Delete();
- }
-
- foreach (DirectoryInfo dir in dirInfo.EnumerateDirectories())
- {
- dir.Delete(true);
- }
- }
-
- }
-}
diff --git a/tests/src/Common/CoreFX/TestFileSetup/Helpers/TestRunHelper.cs b/tests/src/Common/CoreFX/TestFileSetup/Helpers/TestRunHelper.cs
deleted file mode 100644
index a8a97916c5..0000000000
--- a/tests/src/Common/CoreFX/TestFileSetup/Helpers/TestRunHelper.cs
+++ /dev/null
@@ -1,158 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace CoreFX.TestUtils.TestFileSetup.Helpers
-{
- /// <summary>
- /// A class which runs all tests conforming to the current format of CoreFX tests -
- /// Each folder:
- /// is named for the test it contains - e.g. System.Collections.Tests
- /// contains a test assembly named for the library it tests - e.g. System.Collections.Tests.dll
- /// contains a test executable with the specified name - e.g. xunit.console.netcore.exe
- /// </summary>
- public class NetCoreTestRunHelper
- {
-
- public string DotnetExecutablePath { get; set; }
-
- public string logRootOutputPath { get; set; }
-
- /// <summary>
- /// Default Constructor
- /// </summary>
- /// <param name="DotnetExecutablePath"> Path to the dotnet executable, which is used to run the test executable In CoreFX tests this will be the built test host</param>
- /// <param name="logRootOutputPath">Path to which to output test run logs</param>
- public NetCoreTestRunHelper(string DotnetExecutablePath, string logRootOutputPath)
- {
- this.DotnetExecutablePath = DotnetExecutablePath;
- this.logRootOutputPath = logRootOutputPath;
- }
-
- /// <summary>
- /// Run a single test executabke
- /// </summary>
- /// <param name="workingDirectory">Directory from which to start the test executable</param>
- /// <param name="executableName">Name of the test executable</param>
- /// <param name="xunitTestTraits">Test trait exclusions to pass to the runner.</param>
- /// <param name="logOutputPath">Path to which to output the single test run's results</param>
- /// <returns>0 if single test run is succesful; 1 if not</returns>
- public int RunExecutable(string workingDirectory, string executableName, IReadOnlyList<string> xunitTestTraits, string logOutputPath)
- {
- // Calculate and create the path to the test log
- string logPath = Path.Combine(logOutputPath, Path.GetFileName(workingDirectory));
- if (!Directory.Exists(logPath))
- Directory.CreateDirectory(logPath);
-
- // Calculate the arguments to pass to the test runner
- string arguments = CalculateCommandLineArguments(workingDirectory, executableName, xunitTestTraits, Path.Combine(logPath,"testResults.xml"));
-
- // Create and initialize the test executable process
- ProcessStartInfo startInfo = new ProcessStartInfo(DotnetExecutablePath, arguments)
- {
- Arguments = arguments,
- WorkingDirectory = workingDirectory
- };
-
-
- Process executableProcess = new Process();
- executableProcess.StartInfo = startInfo;
- executableProcess.EnableRaisingEvents = true;
- executableProcess.Start();
- executableProcess.WaitForExit();
-
- return executableProcess.ExitCode;
- }
- /// <summary>
- /// Run all test executables conforming to the specified pattern in a directory
- /// </summary>
- /// <param name="rootDirectory">Directory containing tests to run</param>
- /// <param name="executableName">Name of the test executable contained in folders</param>
- /// <param name="xunitTestTraits">Test trait exclusions to pass to the runner.</param>
- /// <param name="processLimit">Maximum number of tests to run in parallel</param>
- /// <param name="logRootOutputPath">Root path to which to output the all test runs' results</param>
- /// <returns>0 if entire test run is succesful; 1 if not</returns>
- public int RunAllExecutablesInDirectory(string rootDirectory, string executableName, IReadOnlyList<string> xunitTestTraits, int processLimit, string logRootOutputPath = null)
- {
- int result = 0;
- // Do a Depth-First Search to find and run executables with the same name
- Stack<string> directories = new Stack<string>();
- List<string> testDirectories = new List<string>();
- // Push rootdir
- directories.Push(rootDirectory);
-
- while (directories.Count > 0)
- {
- string currentDirectory = directories.Pop();
-
- // If a directory contains an executable with the specified name - add it
- if (File.Exists(Path.Combine(currentDirectory, executableName)))
- testDirectories.Add(currentDirectory);
-
- foreach (string subDir in Directory.GetDirectories(currentDirectory))
- directories.Push(subDir);
- }
-
- // Initialize max degree of parallelism
- ParallelOptions parallelOptions = new ParallelOptions();
- parallelOptions.MaxDegreeOfParallelism = processLimit;
-
- Parallel.ForEach(testDirectories, parallelOptions,
- (testDirectory) =>
- {
- if (RunExecutable(testDirectory, executableName, xunitTestTraits, logRootOutputPath) != 0)
- {
- // If any tests fail mark the whole run as failed
- Console.WriteLine("Test Run Failed " + testDirectory);
- result = 1;
- }
- }
- );
- return result;
- }
-
- /// <summary>
- /// Calculate the commandline arguments to pass to the test executable
- /// </summary>
- /// <param name="testDirectory">Current test directory name - assumed to have the same name as the test</param>
- /// <param name="executableName">>Name of the test executable contained in the folder</param>
- /// <param name="xunitTestTraits">Test trait exclusions to pass to the runner.</param>
- /// <param name="logPath">Path to which to output the single test run's results</param>
- /// <returns>A string representing command line arguments to be passed to the console test runner</returns>
- private string CalculateCommandLineArguments(string testDirectory, string executableName, IReadOnlyList<string> xunitTestTraits, string logPath)
- {
- StringBuilder arguments = new StringBuilder();
-
- // Append test executable name
- arguments.Append($"\"{Path.Combine(testDirectory, Path.GetFileName(executableName))}\" ");
-
- // Append test name dll\
- arguments.Append($"\"{Path.Combine(testDirectory, Path.GetFileName(testDirectory))}.dll\" ");
-
- // Append RSP file
- arguments.Append($"@\"{Path.Combine(testDirectory, Path.GetFileName(testDirectory))}.rsp\" ");
-
- if (!String.IsNullOrEmpty(logPath))
- {
- // Add logging information
- arguments.Append($"-xml {logPath} ");
- }
-
- // Append all additional arguments
- foreach (string traitToExclude in xunitTestTraits)
- {
- arguments.Append($"-notrait {traitToExclude} ");
- }
-
- return arguments.ToString();
- }
- }
-}
diff --git a/tests/src/Common/CoreFX/TestFileSetup/Program.cs b/tests/src/Common/CoreFX/TestFileSetup/Program.cs
deleted file mode 100644
index 599dd6d717..0000000000
--- a/tests/src/Common/CoreFX/TestFileSetup/Program.cs
+++ /dev/null
@@ -1,174 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Collections.Generic;
-using System.CommandLine;
-using System.IO;
-using System.Net.Http;
-using System.Text;
-using CoreFX.TestUtils.TestFileSetup.Helpers;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Schema;
-
-namespace CoreFX.TestUtils.TestFileSetup
-{
- /// <summary>
- /// This is a driver class, which downloads archived CoreFX test assemblies from a specified URL, lays out their contents
- /// and subsequently runs them in parallel.
- /// This is invoked from .tests/runtests.[cmd|sh] and depends on a test host (CoreCLR components with a dotnet executable) being present
- /// </summary>
- public class Program
- {
- // Helper class to lay out files on disk
- private static TestFileHelper testFileHelper;
- // Helper class to run tests in parallel
- private static NetCoreTestRunHelper testRunHelper;
-
- // Test Set-up Options
- private static string outputDir;
- private static string testUrl;
- private static string testListPath;
- private static bool cleanTestBuild;
-
- // Test Run Options
- private static string dotnetPath;
- private static bool runSpecifiedTests;
- private static bool runAllTests;
- private static int maximumDegreeOfParalellization;
- private static string logRootOutputPath;
-
- private static ExitCode exitCode;
- private static string executableName;
- private static IReadOnlyList<string> traitExclusions = Array.Empty<string>();
-
- public static void Main(string[] args)
- {
- // Initialize default options
- exitCode = ExitCode.Success;
- maximumDegreeOfParalellization = Environment.ProcessorCount;
- runSpecifiedTests = false;
- runAllTests = false;
- cleanTestBuild = false;
-
- ArgumentSyntax argSyntax = ParseCommandLine(args);
- try
- {
- // Download and lay out files on disk
- SetupTests(runAllTests);
-
- // Only run tests if the relevant commandline switch is passed
- if (runSpecifiedTests || runAllTests)
- exitCode = RunTests();
- }
- catch (AggregateException e)
- {
- // Handle failure cases and exit gracefully
- e.Handle(innerExc =>
- {
-
- if (innerExc is HttpRequestException)
- {
- exitCode = ExitCode.HttpError;
- Console.WriteLine("Error downloading tests from: " + testUrl);
- Console.WriteLine(innerExc.Message);
- return true;
- }
- else if (innerExc is IOException)
- {
- exitCode = ExitCode.IOError;
- Console.WriteLine(innerExc.Message);
- return true;
- }
- else if (innerExc is JSchemaValidationException || innerExc is JsonSerializationException)
- {
- exitCode = ExitCode.JsonSchemaValidationError;
- Console.WriteLine("Error validating test list: ");
- Console.WriteLine(innerExc.Message);
- return true;
- }
- else
- {
- exitCode = ExitCode.UnknownError;
- }
-
- return false;
- });
- }
-
- Environment.Exit((int)exitCode);
- }
-
- /// <summary>
- /// Parse passed Command Line arguments
- /// </summary>
- /// <param name="args"></param>
- /// <returns></returns>
- private static ArgumentSyntax ParseCommandLine(string[] args)
- {
- ArgumentSyntax argSyntax = ArgumentSyntax.Parse(args, syntax =>
- {
- syntax.DefineOption("out|outDir|outputDirectory", ref outputDir, "Directory where tests are downloaded");
- syntax.DefineOption("testUrl", ref testUrl, "URL, pointing to the list of tests");
- syntax.DefineOption("testListJsonPath", ref testListPath, "JSON-formatted list of test assembly names to download");
- syntax.DefineOption("clean|cleanOutputDir", ref cleanTestBuild, "Clean test assembly output directory");
- syntax.DefineOption("runSpecified|runSpecifiedTests", ref runSpecifiedTests, "Run specified Tests after setup");
- syntax.DefineOption("runAll|runAllTests", ref runAllTests, "Run All available Tests in the specified TestList");
- syntax.DefineOption("dotnet|dotnetPath", ref dotnetPath, "Path to dotnet executable used to run tests.");
- syntax.DefineOption("executable|executableName", ref executableName, "Name of the test executable to start");
- syntax.DefineOption("log|logPath|logRootOutputPath", ref logRootOutputPath, "Run Tests after setup");
- syntax.DefineOption("maxProcessCount|numberOfParallelTests|maximumDegreeOfParalellization", ref maximumDegreeOfParalellization, "Maximum number of concurrently executing processes");
- syntax.DefineOptionList("notrait", ref traitExclusions, "Traits to be excluded from test runs");
-
- });
-
- if (runSpecifiedTests || runAllTests)
- {
- if (String.IsNullOrEmpty(dotnetPath))
- throw new ArgumentException("Please supply a test host location to run tests.");
-
- if (!File.Exists(dotnetPath))
- throw new ArgumentException("Invalid testhost path. Please supply a test host location to run tests.");
- }
-
- return argSyntax;
- }
-
- /// <summary>
- /// Method, which calls into the Test File Setup helper class to download and layout test assemblies on disk
- /// </summary>
- /// <param name="runAll">Specifies whether all tests available in the test list should be run</param>
- private static void SetupTests(bool runAll = false)
- {
- testFileHelper = new TestFileHelper();
-
- if (!Directory.Exists(outputDir))
- Directory.CreateDirectory(outputDir);
-
- // If the --clean switch has been specified delete existing assemblies
- if (cleanTestBuild)
- {
- testFileHelper.CleanBuild(outputDir);
- }
-
- // Map test names to their definitions
- Dictionary<string, XUnitTestAssembly> testAssemblyDefinitions = testFileHelper.DeserializeTestJson(testListPath);
-
- testFileHelper.SetupTests(testUrl, outputDir, testAssemblyDefinitions, runAll).Wait();
- }
-
- /// <summary>
- /// Runs all tests in a directory
- /// Only tests, the executable driver of which has the same name as the passed argument are executed - e.g. xunit.console.netcore.exe
- /// </summary>
- /// <returns></returns>
- private static ExitCode RunTests()
- {
- testRunHelper = new NetCoreTestRunHelper(dotnetPath, logRootOutputPath);
- int result = testRunHelper.RunAllExecutablesInDirectory(outputDir, executableName, traitExclusions, maximumDegreeOfParalellization, logRootOutputPath);
-
- return result == 0 ? ExitCode.Success : ExitCode.TestFailure;
- }
- }
-}
diff --git a/tests/src/Common/CoreFX/TestFileSetup/RSPGenerator.cs b/tests/src/Common/CoreFX/TestFileSetup/RSPGenerator.cs
deleted file mode 100644
index ae323026ca..0000000000
--- a/tests/src/Common/CoreFX/TestFileSetup/RSPGenerator.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-
-namespace CoreFX.TestUtils.TestFileSetup
-{
- /// <summary>
- /// A class which generates .rsp files to be passed to the test executable
- /// The file contains a list of methods, classes and namespaces to be excluded from running.
- /// </summary>
- public class RSPGenerator
- {
- /// <summary>
- /// Generate an rsp file from an XUnitTestAssembly class
- /// </summary>
- /// <param name="testDefinition">The XUnitTestAssembly object parsed from a specified test list</param>
- /// <param name="outputPath">Path to which to output a .rsp file</param>
- public void GenerateRSPFile(XUnitTestAssembly testDefinition, string outputPath)
- {
- if (!Directory.Exists(outputPath))
- {
- Directory.CreateDirectory(outputPath);
- }
- string rspFilePath = Path.Combine(outputPath, testDefinition.Name + ".rsp");
-
- if (File.Exists(rspFilePath))
- File.Delete(rspFilePath);
-
- // Write RSP file to disk
- using (StreamWriter sr = File.CreateText(rspFilePath))
- {
- // If no exclusions are defined, we don't need to generate an .rsp file
- if (testDefinition.Exclusions == null)
- return;
-
- // Method exclusions
- if (testDefinition.Exclusions.Methods != null)
- {
- foreach (Exclusion exclusion in testDefinition.Exclusions.Methods)
- {
- if (String.IsNullOrWhiteSpace(exclusion.Name))
- continue;
- sr.Write("-skipmethod ");
- sr.Write(exclusion.Name);
- sr.WriteLine();
- }
- }
-
- // Class exclusions
- if (testDefinition.Exclusions.Classes != null)
- {
- foreach (Exclusion exclusion in testDefinition.Exclusions.Classes)
- {
- if (String.IsNullOrWhiteSpace(exclusion.Name))
- continue;
- sr.Write("-skipclass ");
- sr.Write(exclusion.Name);
- sr.WriteLine();
- }
-
- }
-
- // Namespace exclusions
- if (testDefinition.Exclusions.Namespaces != null)
- {
- foreach (Exclusion exclusion in testDefinition.Exclusions.Namespaces)
- {
- if (String.IsNullOrWhiteSpace(exclusion.Name))
- continue;
- sr.Write("-skipnamespace ");
- sr.Write(exclusion.Name);
- sr.WriteLine();
- }
- }
- }
- }
- }
-}
diff --git a/tests/src/Common/CoreFX/TestFileSetup/XUnit/XUnitTestAssembly.cs b/tests/src/Common/CoreFX/TestFileSetup/XUnit/XUnitTestAssembly.cs
deleted file mode 100644
index efe78853c8..0000000000
--- a/tests/src/Common/CoreFX/TestFileSetup/XUnit/XUnitTestAssembly.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Newtonsoft.Json;
-
-namespace CoreFX.TestUtils.TestFileSetup
-{
- /// <summary>
- /// A class representing a CoreFX test assembly to be run
- /// </summary>
- public class XUnitTestAssembly
- {
- [JsonRequired]
- [JsonProperty("name")]
- public string Name;
-
- [JsonRequired]
- [JsonProperty("enabled")]
- public bool IsEnabled;
-
- [JsonRequired]
- [JsonProperty("exclusions")]
- public Exclusions Exclusions;
-
- // Used to assign a test url or to override it via the json file definition - mark it as optional in the test definition
- [JsonIgnore]
- [JsonProperty(Required = Required.Default)]
- public string Url;
-
- }
- /// <summary>
- /// Class representing a collection of test exclusions
- /// </summary>
- public class Exclusions
- {
- [JsonProperty("namespaces")]
- public Exclusion[] Namespaces;
-
- [JsonProperty("classes")]
- public Exclusion[] Classes;
-
- [JsonProperty("methods")]
- public Exclusion[] Methods;
- }
-
- /// <summary>
- /// Class representing a single test exclusion
- /// </summary>
- public class Exclusion
- {
- [JsonRequired]
- [JsonProperty("name", Required = Required.DisallowNull)]
- public string Name;
-
- [JsonRequired]
- [JsonProperty("reason", Required = Required.DisallowNull)]
- public string Reason;
- }
-}