From edb1e3fce73aa91281674648614b4bacdf5a5f4e Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Tue, 18 Jul 2023 16:15:20 -0400 Subject: [PATCH] Fix the -map-threads test --- .github/workflows/ci-pipeline.yml | 6 ++ tests/Tgstation.Server.Tests/TestVersions.cs | 75 ++++++++++---------- 2 files changed, 44 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index 0e3cca5579..c6b420c33c 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -237,6 +237,12 @@ jobs: TGS_TEST_IRC_CONNECTION_STRING: ${{ secrets.IRC_CONNECTION_STRING }} runs-on: ubuntu-latest steps: + - name: Install x86 libc Dependencies + run: | + sudo dpkg --add-architecture i386 + sudo apt-get update + sudo apt-get install -y -o APT::Immediate-Configure=0 libc6-i386 libstdc++6:i386 libgcc-s1:i386 + - name: Setup dotnet uses: actions/setup-dotnet@v2 with: diff --git a/tests/Tgstation.Server.Tests/TestVersions.cs b/tests/Tgstation.Server.Tests/TestVersions.cs index 875282d1f7..41c48a1196 100644 --- a/tests/Tgstation.Server.Tests/TestVersions.cs +++ b/tests/Tgstation.Server.Tests/TestVersions.cs @@ -156,25 +156,18 @@ namespace Tgstation.Server.Tests }); var platformIdentifier = new PlatformIdentifier(); - try - { - var logger = loggerFactory.CreateLogger(); - var init1 = CachingFileDownloader.InitializeByondVersion( - logger, - ByondInstallerBase.MapThreadsVersion, - platformIdentifier.IsWindows, - CancellationToken.None); - await CachingFileDownloader.InitializeByondVersion( - logger, - new Version(ByondInstallerBase.MapThreadsVersion.Major, ByondInstallerBase.MapThreadsVersion.Minor - 1), - platformIdentifier.IsWindows, - CancellationToken.None); - await init1; - } - catch (HttpRequestException ex) when (ex.StatusCode == HttpStatusCode.NotFound) - { - Assert.Inconclusive("-map-threads version appears to not have been released yet!"); - } + var logger = loggerFactory.CreateLogger(); + var init1 = CachingFileDownloader.InitializeByondVersion( + logger, + ByondInstallerBase.MapThreadsVersion, + platformIdentifier.IsWindows, + CancellationToken.None); + await CachingFileDownloader.InitializeByondVersion( + logger, + new Version(ByondInstallerBase.MapThreadsVersion.Major, ByondInstallerBase.MapThreadsVersion.Minor - 1), + platformIdentifier.IsWindows, + CancellationToken.None); + await init1; var fileDownloader = new CachingFileDownloader(Mock.Of>()); @@ -186,8 +179,8 @@ namespace Tgstation.Server.Tests mockGeneralConfigurationOptions.Object, loggerFactory.CreateLogger()) : new PosixByondInstaller( - Mock.Of(), - Mock.Of(), + new PosixPostWriteHandler(loggerFactory.CreateLogger()), + new DefaultIOManager(), fileDownloader, loggerFactory.CreateLogger()); using var disposable = byondInstaller as IDisposable; @@ -217,6 +210,8 @@ namespace Tgstation.Server.Tests processExecutor, tempPath); + await ioManager.DeleteDirectory(tempPath, default); + var (byondBytes, version) = await GetByondVersionPriorTo(byondInstaller, ByondInstallerBase.MapThreadsVersion); await TestMapThreadsVersion( @@ -231,8 +226,6 @@ namespace Tgstation.Server.Tests { await ioManager.DeleteDirectory(tempPath, default); } - - Assert.Fail("Test succeeded, but remove the 404 workaround!"); } [ClassCleanup] @@ -425,29 +418,37 @@ namespace Tgstation.Server.Tests Assert.IsTrue(supportsCli); - await using var process = processExecutor.LaunchProcess( - ddPath, - Environment.CurrentDirectory, - "fake.dmb -map-threads 3 -close", - null, - true, - true); + await File.WriteAllBytesAsync("fake.dmb", Array.Empty(), CancellationToken.None); try { - await process.Startup; + await using var process = processExecutor.LaunchProcess( + ddPath, + Environment.CurrentDirectory, + "fake.dmb -map-threads 3 -close", + null, + true, + true); - using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await process.Lifetime.WaitAsync(cts.Token); + try + { + await process.Startup; + using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + await process.Lifetime.WaitAsync(cts.Token); - var output = await process.GetCombinedOutput(cts.Token); + var output = await process.GetCombinedOutput(cts.Token); - var supportsMapThreads = !output.Contains("invalid option '-map-threads'"); - Assert.AreEqual(shouldSupportMapThreads, supportsMapThreads, $"DD Output:{Environment.NewLine}{output}"); + var supportsMapThreads = !output.Contains("invalid option '-map-threads'"); + Assert.AreEqual(shouldSupportMapThreads, supportsMapThreads, $"DD Output:{Environment.NewLine}{output}"); + } + finally + { + process.Terminate(); + } } finally { - process.Terminate(); + File.Delete("fake.dmb"); } }