From 32d82bde41b3f6e1e582bc1eb9ae03a35084a449 Mon Sep 17 00:00:00 2001 From: Friedrich von Never Date: Mon, 17 Jul 2023 00:16:11 +0200 Subject: [PATCH] (#380) IntegrationTests: cleanup and run all --- .../Cesium.IntegrationTests.csproj | 18 +- Cesium.IntegrationTests/ExecUtil.cs | 12 +- .../IntegrationTestContext.cs | 13 +- .../IntegrationTestRunner.cs | 37 ++- Cesium.IntegrationTests/Run-Tests.ps1 | 164 ---------- Cesium.TestAdapter/Cesium.TestAdapter.csproj | 13 - Cesium.TestAdapter/CompilerVerifier.cs | 293 ------------------ Cesium.sln | 6 - Cesium.sln.DotSettings | 4 +- 9 files changed, 50 insertions(+), 510 deletions(-) delete mode 100644 Cesium.IntegrationTests/Run-Tests.ps1 delete mode 100644 Cesium.TestAdapter/Cesium.TestAdapter.csproj delete mode 100644 Cesium.TestAdapter/CompilerVerifier.cs diff --git a/Cesium.IntegrationTests/Cesium.IntegrationTests.csproj b/Cesium.IntegrationTests/Cesium.IntegrationTests.csproj index 1835defd..f6e249c3 100644 --- a/Cesium.IntegrationTests/Cesium.IntegrationTests.csproj +++ b/Cesium.IntegrationTests/Cesium.IntegrationTests.csproj @@ -8,26 +8,16 @@ - - Always - - - Always - - - - + + + - - - - - + diff --git a/Cesium.IntegrationTests/ExecUtil.cs b/Cesium.IntegrationTests/ExecUtil.cs index 99019948..70cd6265 100644 --- a/Cesium.IntegrationTests/ExecUtil.cs +++ b/Cesium.IntegrationTests/ExecUtil.cs @@ -7,7 +7,7 @@ namespace Cesium.IntegrationTests; internal static class ExecUtil { public static void RunToSuccess( - ITestOutputHelper output, + ITestOutputHelper? output, string executable, string workingDirectory, string[] args) @@ -17,22 +17,22 @@ public static void RunToSuccess( } public static CommandResult Run( - ITestOutputHelper output, + ITestOutputHelper? output, string executable, string workingDirectory, string[] args) { - output.WriteLine($"$ {executable} {string.Join(" ", args)}"); + output?.WriteLine($"$ {executable} {string.Join(" ", args)}"); var result = Command.Run(executable, args, o => o.WorkingDirectory(workingDirectory)).Result; foreach (var s in result.StandardOutput.Split("\n")) - output.WriteLine(s.TrimEnd()); + output?.WriteLine(s.TrimEnd()); if (result.StandardError.Trim() != "") { foreach (var s in result.StandardError.Split("\n")) - output.WriteLine($"[ERR] {s.TrimEnd()}"); + output?.WriteLine($"[ERR] {s.TrimEnd()}"); } - output.WriteLine($"Command exit code: {result.ExitCode}"); + output?.WriteLine($"Command exit code: {result.ExitCode}"); return result; } } diff --git a/Cesium.IntegrationTests/IntegrationTestContext.cs b/Cesium.IntegrationTests/IntegrationTestContext.cs index 565d7a98..de7aee37 100644 --- a/Cesium.IntegrationTests/IntegrationTestContext.cs +++ b/Cesium.IntegrationTests/IntegrationTestContext.cs @@ -5,9 +5,9 @@ namespace Cesium.IntegrationTests; [UsedImplicitly] -public class IntegrationTestContext +public class IntegrationTestContext : IDisposable { - public readonly string SolutionRootPath = GetSolutionRoot(); + public static readonly string SolutionRootPath = GetSolutionRoot(); public const string BuildConfiguration = "Release"; private readonly object _lock = new(); private bool _initialized; @@ -40,6 +40,15 @@ public void EnsureInitialized(ITestOutputHelper output) } } + public void Dispose() + { + ExecUtil.RunToSuccess(null, "dotnet", SolutionRootPath, new[] + { + "build-server", + "shutdown" + }); + } + private static string GetSolutionRoot() { var assemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); diff --git a/Cesium.IntegrationTests/IntegrationTestRunner.cs b/Cesium.IntegrationTests/IntegrationTestRunner.cs index 3c422e8a..c2d3dd79 100644 --- a/Cesium.IntegrationTests/IntegrationTestRunner.cs +++ b/Cesium.IntegrationTests/IntegrationTestRunner.cs @@ -6,16 +6,24 @@ namespace Cesium.IntegrationTests; public class IntegrationTestRunner : IClassFixture { private readonly ITestOutputHelper _output; - private readonly string _solutionRootPath; public IntegrationTestRunner(IntegrationTestContext context, ITestOutputHelper output) { _output = output; context.EnsureInitialized(output); - _solutionRootPath = context.SolutionRootPath; + } + + public static IEnumerable TestCaseProvider() + { + var testCaseDirectory = Path.Combine(IntegrationTestContext.SolutionRootPath, "Cesium.IntegrationTests"); + var cFiles = Directory.EnumerateFileSystemEntries(testCaseDirectory, "*.c", SearchOption.AllDirectories); + return cFiles + .Where(file => !file.EndsWith(".ignore.c")) + .Select(file => Path.GetRelativePath(testCaseDirectory, file)) + .Select(path => new object[] { path }); } [Theory] - [InlineData("arithmetics.c")] + [MemberData(nameof(TestCaseProvider))] public void TestCompiler(string relativeFilePath) { var outRootPath = CreateTempDir(); @@ -28,7 +36,10 @@ public void TestCompiler(string relativeFilePath) Directory.CreateDirectory(binDirPath); Directory.CreateDirectory(objDirPath); - var sourceFilePath = Path.Combine(_solutionRootPath, "Cesium.IntegrationTests", relativeFilePath); + var sourceFilePath = Path.Combine( + IntegrationTestContext.SolutionRootPath, + "Cesium.IntegrationTests", + relativeFilePath); var nativeExecutable = BuildExecutableWithNativeCompiler(binDirPath, objDirPath, sourceFilePath); var nativeResult = ExecUtil.Run(_output, nativeExecutable, outRootPath, Array.Empty()); @@ -38,7 +49,9 @@ public void TestCompiler(string relativeFilePath) var managedResult = ExecUtil.Run(_output, "dotnet", outRootPath, new[] { managedExecutable }); // TODO: Only .NET for now Assert.Equal(42, managedResult.ExitCode); - Assert.Equal(nativeResult.StandardOutput, managedResult.StandardOutput); + Assert.Equal( + nativeResult.StandardOutput.ReplaceLineEndings("\n"), + managedResult.StandardOutput.ReplaceLineEndings("\n")); Assert.Empty(nativeResult.StandardError); Assert.Empty(managedResult.StandardError); } @@ -48,12 +61,16 @@ public void TestCompiler(string relativeFilePath) } } + private static readonly object _tempDirCreator = new(); private string CreateTempDir() { - var path = Path.GetTempFileName(); - File.Delete(path); - Directory.CreateDirectory(path); - return path; + lock (_tempDirCreator) + { + var path = Path.GetTempFileName(); + File.Delete(path); + Directory.CreateDirectory(path); + return path; + } } private string BuildExecutableWithNativeCompiler( @@ -130,7 +147,7 @@ private string BuildExecutableWithCesium( "run", "--no-build", "--configuration", IntegrationTestContext.BuildConfiguration, - "--project", Path.Combine(_solutionRootPath, "Cesium.Compiler"), + "--project", Path.Combine(IntegrationTestContext.SolutionRootPath, "Cesium.Compiler"), "--", "--nologo", sourceFilePath, diff --git a/Cesium.IntegrationTests/Run-Tests.ps1 b/Cesium.IntegrationTests/Run-Tests.ps1 deleted file mode 100644 index 982af82d..00000000 --- a/Cesium.IntegrationTests/Run-Tests.ps1 +++ /dev/null @@ -1,164 +0,0 @@ -# TODO: Remove this file -param ( - $SourceRoot = "$PSScriptRoot/..", - $OutDir = "$PSScriptRoot/bin", - $ObjDir = "$PSScriptRoot/obj", - $TestCaseDir = "$PSScriptRoot", - $TargetFramework = "Net", - $Configuration = "Release", - $TestCaseName = $null -) - -Set-StrictMode -Version Latest -$ErrorActionPreference = 'Stop' - -function buildFileWithNativeCompiler($inputFile, $outputFile) { - if ($IsWindows) { - Write-Host "Compiling $inputFile with cl.exe." - cl.exe /nologo $inputFile -D__TEST_DEFINE /Fo:$ObjDir/ /Fe:$outputFile | Out-Host - } else { - Write-Host "Compiling $inputFile with gcc." - gcc $inputFile -o $outputFile -D__TEST_DEFINE | Out-Host - } - - if (!$?) { - Write-Host "Error: native compiler returned exit code $LASTEXITCODE." - return $false - } - - return $true -} - -function buildFileWithCesium($inputFile, $outputFile) { - # $env:Platform will override the output directory for dotnet run, so let's remove it temporarily. - $oldPlatform = $env:Platform - $env:Platform = $null - try { - Write-Host "Compiling $inputFile with Cesium." - if ($TargetFramework -eq "NetFramework") - { - $CoreLib = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll" - $CesiumRuntime = "$SourceRoot/Cesium.Runtime/bin/$Configuration/netstandard2.0/Cesium.Runtime.dll" - dotnet run --no-build --configuration $Configuration --project "$SourceRoot/Cesium.Compiler" -- --nologo $inputFile --out $outputFile -D__TEST_DEFINE --framework $TargetFramework --corelib $CoreLib --runtime $CesiumRuntime | Out-Host - } - else - { - dotnet run --no-build --configuration $Configuration --project "$SourceRoot/Cesium.Compiler" -- --nologo $inputFile --out $outputFile -D__TEST_DEFINE --framework $TargetFramework | Out-Host - } - - if (!$?) { - Write-Host "Error: Cesium.Compiler returned exit code $LASTEXITCODE." - return $false - } - - return $true - } finally { - $env:Platform = $oldPlatform - } -} - -function validateTestCase($testCase) { - $nativeCompilerBinOutput = "$outDir/out_native.exe" - $cesiumBinOutput = "$outDir/out_cs.exe" - - $nativeCompilerRunLog = "$outDir/out_native.log" - $cesiumRunLog = "$outDir/out_cs.log" - - $expectedExitCode = 42 - - if (!(buildFileWithNativeCompiler $testCase $nativeCompilerBinOutput)) { - return $false - } - - & $nativeCompilerBinOutput | Out-File -Encoding utf8 $nativeCompilerRunLog - if ($LASTEXITCODE -ne $expectedExitCode) { - Write-Host "Binary $nativeCompilerBinOutput returned code $LASTEXITCODE, but $expectedExitCode was expected." - return $false - } - - if (!(buildFileWithCesium $testCase $cesiumBinOutput)) { - return $false - } - - if ($TargetFramework -eq "NetFramework") - { - & $cesiumBinOutput | Out-File -Encoding utf8 $cesiumRunLog - } - else - { - dotnet $cesiumBinOutput | Out-File -Encoding utf8 $cesiumRunLog - } - - if ($LASTEXITCODE -ne $expectedExitCode) { - Write-Host "Binary $cesiumBinOutput returned code $LASTEXITCODE, but $expectedExitCode was expected." - return $false - } - - $nativeCompilerOutput = Get-Content -LiteralPath $nativeCompilerRunLog -Raw - $cesiumOutput = Get-Content -LiteralPath $cesiumRunLog -Raw - if ($nativeCompilerOutput -ne $cesiumOutput) { - Write-Host "Output for $testCase differs between native- and Cesium-compiled programs." - Write-Host "cl.exe ($testCase):`n$nativeCompilerOutput`n" - Write-Host "Cesium ($testCase):`n$cesiumOutput" - return $false - } - - $true -} - -function formatCount($count, $singular, $plural) { - if ($count -eq 1) { - return "$count $singular" - } else { - return "$count $plural" - } -} - -Write-Host "Cleaning up $ObjDir and $OutDir." -if (Test-Path $ObjDir) { - Remove-Item -Recurse $ObjDir -} -if (Test-Path $OutDir) { - Remove-Item -Recurse $OutDir -} - -New-Item $ObjDir -Type Directory | Out-Null -New-Item $OutDir -Type Directory | Out-Null - -$successfulTests = @() -$failedTests = @() -if ($TestCaseName) { - Write-Host "Running tests for single case $TestCaseName." - $testCase = "$TestCaseDir/$TestCaseName" - if (validateTestCase $testCase) { - Write-Host "$($testCase): ok." - $successfulTests += $testCase - } else { - Write-Host "$($testCase): failed." - $failedTests += $testCase - } -} else { - $allTestCases = Get-ChildItem "$TestCaseDir/*.c" -Exclude "*.ignore.c" -Recurse - Write-Host -ForegroundColor White "Running tests for $($allTestCases.Count) cases." - foreach ($testCase in $allTestCases) { - $currentTestName = [IO.Path]::GetRelativePath($TestCaseDir, $testCase) - Write-Host -ForegroundColor White "# $currentTestName" - - if (validateTestCase $testCase) { - Write-Host -ForegroundColor Green "$($currentTestName): ok." - $successfulTests += $testCase - } else { - Write-Host -ForegroundColor Red "$($currentTestName): failed." - $failedTests += $testCase - } - - Write-Host '' - } -} - -if ($failedTests.Count -gt 0) { - $testNames = $failedTests -join "`n" - throw "Errors in the following $(formatCount $failedTests.Count "test" "tests"): $testNames" -} else { - Write-Host -ForegroundColor Green "$(formatCount $successfulTests.Count "test has" "tests have") been executed successfully." -} diff --git a/Cesium.TestAdapter/Cesium.TestAdapter.csproj b/Cesium.TestAdapter/Cesium.TestAdapter.csproj deleted file mode 100644 index ee4f6989..00000000 --- a/Cesium.TestAdapter/Cesium.TestAdapter.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - net7.0 - enable - enable - - - - - - - diff --git a/Cesium.TestAdapter/CompilerVerifier.cs b/Cesium.TestAdapter/CompilerVerifier.cs deleted file mode 100644 index 463fb738..00000000 --- a/Cesium.TestAdapter/CompilerVerifier.cs +++ /dev/null @@ -1,293 +0,0 @@ -using System.Diagnostics; -using System.Runtime.Versioning; -using System.Text; -using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; -using Microsoft.Win32; - -namespace Cesium.TestAdapter; - -// TODO: Delete this file and the whole project if no longer needed -internal class CompilerVerifier -{ - private readonly string _sourceFolder; - private readonly string _container; - - public CompilerVerifier(string container) - { - _container = Path.GetDirectoryName(container)!; - _sourceFolder = FindRootFolder(container); - } - - public string OutDir => Path.Combine(_sourceFolder, "Cesium.IntegrationTests", "bin"); - public string ObjDir => Path.Combine(_sourceFolder, "Cesium.IntegrationTests", "obj"); - public string TestCaseDir => Path.Combine(_sourceFolder, "Cesium.IntegrationTests"); - public string TargetFramework => "Net"; - public string Configuration => "Release"; - public string SourceRoot => _sourceFolder; - - private static string FindRootFolder(string file) - { - var directory = Path.GetDirectoryName(file); - if (directory is null) throw new InvalidOperationException("Cannot run from root location"); - var cesiumSolution = Path.Combine(directory, "Cesium.sln"); - while (!File.Exists(cesiumSolution)) - { - directory = Path.GetDirectoryName(directory); - if (directory is null) throw new InvalidOperationException("Cannot run from root location"); - cesiumSolution = Path.Combine(directory, "Cesium.sln"); - } - - return directory; - } - - public void VerifySourceCode(string sourceCodeFile, IMessageLogger logger) - { - var nativeCompilerBinOutput = $"{OutDir}/{Path.GetRelativePath(_container, sourceCodeFile)}.native.exe"; - var cesiumBinOutput = $"{OutDir}/{Path.GetRelativePath(_container, sourceCodeFile)}.cs.exe"; - Directory.CreateDirectory(Path.GetDirectoryName(nativeCompilerBinOutput)!); - //var nativeCompilerRunLog = $"{OutDir}/out_native.log"; - //var cesiumRunLog = $"{OutDir}/out_cs.log"; - - var expectedExitCode = 42; - if (!BuildFileWithNativeCompiler(sourceCodeFile, nativeCompilerBinOutput, logger)) - { - throw new InvalidOperationException("Native compilation failed"); - } - - var exitCode = RunApplication(nativeCompilerBinOutput, "", out var nativeCompilerRunLog); - if (exitCode != expectedExitCode) - { - throw new InvalidOperationException($"Binary {nativeCompilerBinOutput} returned code {exitCode}, but {expectedExitCode} was expected."); - } - - if (!BuildFileWithCesium(sourceCodeFile, cesiumBinOutput, logger)) - { - throw new InvalidOperationException("Cesium compilation failed"); - } - - string cesiumRunLog; - if (TargetFramework == "NetFramework") - { - exitCode = RunApplication(cesiumBinOutput, "", out cesiumRunLog); - } - else - { - exitCode = RunApplication("dotnet", cesiumBinOutput, out cesiumRunLog); - } - - if (exitCode != expectedExitCode) - { - throw new InvalidOperationException($"Binary {cesiumBinOutput} returned code {exitCode}, but {expectedExitCode} was expected."); - } - - var nativeCompilerOutput = nativeCompilerRunLog;//File.ReadAllText(nativeCompilerRunLog); - var cesiumOutput = cesiumRunLog;//File.ReadAllText(cesiumRunLog); - if (nativeCompilerOutput != cesiumOutput) - { - throw new InvalidOperationException($""" - Output for {sourceCodeFile} differs between native- and Cesium-compiled programs. - "cl.exe ({sourceCodeFile}): - {nativeCompilerOutput} - "Cesium ({sourceCodeFile}): - {cesiumOutput} - """); - } - } - - private static int RunApplication(string application, string arguments, out string outputLog) - { - StringBuilder log = new(); - var process = new Process(); - process.StartInfo.FileName = application; - process.StartInfo.Arguments = arguments; - process.StartInfo.UseShellExecute = false; - process.StartInfo.RedirectStandardOutput = true; - process.StartInfo.RedirectStandardError = true; - process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler); - process.ErrorDataReceived += new DataReceivedEventHandler(OutputHandler); - - process.Start(); - process.BeginOutputReadLine(); - process.BeginErrorReadLine(); - process.WaitForExit(); - outputLog = log.ToString(); - return process.ExitCode; - - void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine) - { - lock (log) - { - log.AppendLine(outLine.Data); - } - } - } - - private static string RunApplication(string application, string arguments) - { - _ = RunApplication(application, arguments, out var log); - return log; - } - - [SupportedOSPlatform("windows")] - string FindWin10Sdk() - { - string? path = FindWin10SdkHelper(Registry.LocalMachine, @"SOFTWARE\\Wow6432Node"); - path ??= FindWin10SdkHelper(Registry.CurrentUser, @"SOFTWARE\\Wow6432Node"); - path ??= FindWin10SdkHelper(Registry.LocalMachine, @"SOFTWARE"); - path ??= FindWin10SdkHelper(Registry.CurrentUser, @"SOFTWARE"); - return path ?? throw new InvalidOperationException("Win10 SDK not found"); - } - [SupportedOSPlatform("windows")] - string? FindWin10SdkHelper(RegistryKey hive, string searchLocation) - { - return (string?)hive.OpenSubKey($@"{searchLocation}\Microsoft\Microsoft SDKs\Windows\v10.0")?.GetValue("InstallationFolder"); - } - - private bool BuildFileWithNativeCompiler(string inputFile, string outputFile, IMessageLogger logger) - { - Process? process; - int exitCode; - string output; - if (System.OperatingSystem.IsWindows()) - { - var objDir = ObjDir; - Directory.CreateDirectory(objDir); - var vcInstallationFolder = FindVCCompilerInstallationFolder(); - var pathToCL = Path.Combine(vcInstallationFolder, @"bin\HostX64\x64\cl.exe"); - var pathToLibs = Path.Combine(vcInstallationFolder, @"lib\x64"); - var pathToIncludes = Path.Combine(vcInstallationFolder, @"include"); - var win10SdkPath = FindWin10Sdk(); - string win10Libs = FindLibsFolder(win10SdkPath); - string win10Include = FindIncludeFolder(win10SdkPath); - - var commandLine = $"\"{pathToCL}\" /nologo {inputFile} -D__TEST_DEFINE /Fo:{objDir} /Fe:{outputFile} /I\"{pathToIncludes}\" /I\"{win10Include}\\ucrt\" /link /LIBPATH:\"{pathToLibs}\" /LIBPATH:\"{win10Libs}\\um\\x64\" /LIBPATH:\"{win10Libs}\\ucrt\\x64\""; - logger.SendMessage(TestMessageLevel.Informational, $"Compiling {inputFile} with cl.exe using command line {commandLine}."); - exitCode = RunApplication(pathToCL, $"/nologo {inputFile} -D__TEST_DEFINE /Fo:{objDir} /Fe:{outputFile} /I\"{pathToIncludes}\" /I\"{win10Include}\\ucrt\" /link /LIBPATH:\"{pathToLibs}\" /LIBPATH:\"{win10Libs}\\um\\x64\" /LIBPATH:\"{win10Libs}\\ucrt\\x64\"", out output); - } - else - { - var commandLine = $"gcc {inputFile} -o {outputFile} -D__TEST_DEFINE"; - logger.SendMessage(TestMessageLevel.Informational, $"Compiling {inputFile} with gcc using command line {commandLine}."); - exitCode = RunApplication("gcc", $"{inputFile} -o {outputFile} -D__TEST_DEFINE", out output); - } - - if (exitCode != 0) - { - logger.SendMessage(TestMessageLevel.Warning, $"Error: native compiler returned exit code {exitCode}. {output}"); - return false; - } - - return true; - } - - private static string FindLibsFolder(string win10SdkPath) - { - string? win10Libs = null; - foreach (var versionFolder in Directory.EnumerateDirectories(Path.Combine(win10SdkPath, "Lib"))) - { - var win10LibPathCandidate = Path.Combine(versionFolder, @"um\x64"); - if (Directory.Exists(win10LibPathCandidate)) - win10Libs = versionFolder; - } - - if (win10Libs is null) - { - throw new InvalidOperationException("Windows libs files was not found"); - } - - return win10Libs; - } - - private static string FindIncludeFolder(string win10SdkPath) - { - string? win10Libs = null; - foreach (var versionFolder in Directory.EnumerateDirectories(Path.Combine(win10SdkPath, "Include"))) - { - var win10LibPathCandidate = Path.Combine(versionFolder, @"um"); - if (Directory.Exists(win10LibPathCandidate)) - win10Libs = versionFolder; - } - - if (win10Libs is null) - { - throw new InvalidOperationException("Windows libs files was not found"); - } - - return win10Libs; - } - - private static string FindVCCompilerInstallationFolder() - { - var vswhereLocation = - Environment.ExpandEnvironmentVariables(@"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"); - var installationPath = - RunApplication(vswhereLocation, "-latest -format value -property installationPath -nologo -nocolor"); - if (string.IsNullOrWhiteSpace(installationPath)) - { - installationPath = RunApplication(vswhereLocation, - "-latest -format value -property installationPath -nologo -nocolor -prerelease"); - } - - if (string.IsNullOrWhiteSpace(installationPath)) - { - throw new InvalidOperationException("Visual Studio Installation location was not found"); - } - - var vcRootLocation = Path.Combine(installationPath.Trim(), "VC", "Tools", "MSVC"); - if (!Directory.Exists(vcRootLocation)) - { - throw new InvalidOperationException($"Visual Studio Installation does not have VC++ compiler installed at {vcRootLocation}|{installationPath}"); - } - - string? pathToCL = null; - foreach (var folder in Directory.EnumerateDirectories(vcRootLocation, "14.*", SearchOption.TopDirectoryOnly)) - { - var clPath = Path.Combine(folder, @"bin\HostX64\x64\cl.exe"); - if (File.Exists(clPath)) - pathToCL = folder; - } - - if (pathToCL is null) - { - throw new InvalidOperationException( - "Visual Studio Installation does not have VC++ compiler installed, or it is corrupted"); - } - - return pathToCL; - } - - private bool BuildFileWithCesium(string inputFile, string outputFile, IMessageLogger logger) - { - logger.SendMessage(TestMessageLevel.Informational, $"Compiling {inputFile} with Cesium."); - Process? process; - if (TargetFramework == "NetFramework") - { - var CoreLib = @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll"; - var CesiumRuntime = $"{SourceRoot}/Cesium.Runtime/bin/{Configuration}/netstandard2.0/Cesium.Runtime.dll"; - process = Process.Start($"dotnet", new[] { "run", "--no-build", "--configuration", Configuration, "--project", $"{SourceRoot}/Cesium.Compiler", "--", "--nologo", inputFile, "--out", outputFile, "-D__TEST_DEFINE", "--framework", TargetFramework, "--corelib", CoreLib, "--runtime", CesiumRuntime }); - } - else - { - process = Process.Start($"dotnet", new[] { "run", "--no-build", "--configuration", Configuration, "--project", $"{SourceRoot}/Cesium.Compiler", "--", "--nologo", inputFile, "--out", outputFile, "-D__TEST_DEFINE", "--framework", TargetFramework }); - } - - int exitCode; - if (process is null) - { - exitCode = 8 /*ENOEXEC*/; - } - else - { - process.WaitForExit(); - exitCode = process.ExitCode; - } - - if (exitCode != 0) - { - logger.SendMessage(TestMessageLevel.Informational, $"Error: Cesium.Compiler returned exit code {exitCode}."); - return false; - } - - return true; - } -} diff --git a/Cesium.sln b/Cesium.sln index 7972e927..9d51d83e 100644 --- a/Cesium.sln +++ b/Cesium.sln @@ -78,8 +78,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cesium.Core", "Cesium.Core\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cesium.Runtime.Tests", "Cesium.Runtime.Tests\Cesium.Runtime.Tests.csproj", "{526D8E61-6143-490F-BB9D-E7CD78512E55}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cesium.TestAdapter", "Cesium.TestAdapter\Cesium.TestAdapter.csproj", "{44AE427D-0B53-49BB-B83F-839833002CCE}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -134,10 +132,6 @@ Global {526D8E61-6143-490F-BB9D-E7CD78512E55}.Debug|Any CPU.Build.0 = Debug|Any CPU {526D8E61-6143-490F-BB9D-E7CD78512E55}.Release|Any CPU.ActiveCfg = Release|Any CPU {526D8E61-6143-490F-BB9D-E7CD78512E55}.Release|Any CPU.Build.0 = Release|Any CPU - {44AE427D-0B53-49BB-B83F-839833002CCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {44AE427D-0B53-49BB-B83F-839833002CCE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {44AE427D-0B53-49BB-B83F-839833002CCE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {44AE427D-0B53-49BB-B83F-839833002CCE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Cesium.sln.DotSettings b/Cesium.sln.DotSettings index 2a48a94b..59112c8b 100644 --- a/Cesium.sln.DotSettings +++ b/Cesium.sln.DotSettings @@ -1,6 +1,6 @@  True - + True True True @@ -9,4 +9,4 @@ True True True - True \ No newline at end of file + True