Skip to content

Commit

Permalink
Remove Docker running code from integration tests (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom authored Nov 27, 2022
1 parent db45806 commit 2de5e25
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 54 deletions.
17 changes: 1 addition & 16 deletions test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
Run all tests, verifying the behavior of the test runner.
.PARAMETER UpdateExpected
Update the expected test result files to the current output (optional).
.PARAMETER UseDocker
Run the tests using Docker (optional).
.EXAMPLE
The example below will run all tests
PS C:\> ./test.ps1
The example below will run all tests and update the expected test result files
PS C:\> ./test.ps1 -UpdateExpected
The example below will run all tests using Docker
PS C:\> ./test.ps1 -UseDocker
.NOTES
The UpdateExpected switch should only be used if a bulk update of the expected test result files is needed.
#>
Expand All @@ -40,28 +35,18 @@ function Move-Generated-Test-Results-To-Expected ([string] $SolutionsDir) {
}

function Update-Expected {
$solutionsDir = Join-Path "test" (Join-Path "Exercism.TestRunner.CSharp.IntegrationTests" "Solutions")
$solutionsDir = "tests"

Get-ChildItem $solutionsDir -Directory | ForEach-Object {
Run-Test-Runner $_.FullName
Move-Generated-Test-Results-To-Expected $_.FullName
}
}

function Build-Docker-Image {
docker build -t exercism/csharp-test-runner .
}

if ($UpdateExpected.IsPresent) {
Update-Expected
}

if ($UseDocker.IsPresent) {
Build-Docker-Image
}

$Env:USE_DOCKER = $UseDocker.IsPresent

dotnet test

exit $LastExitCode
13 changes: 0 additions & 13 deletions test/Exercism.TestRunner.CSharp.IntegrationTests/Options.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,7 @@ public static TestRun Run(string directory, string slug = "Fake")
return CreateTestRun(testSolution);
}

private static void RunTestRunner(TestSolution testSolution)
{
if (Options.UseDocker)
RunTestRunnerUsingDocker(testSolution);
else
RunTestRunnerWithoutDocker(testSolution);
}

private static void RunTestRunnerUsingDocker(TestSolution testSolution) =>
Process.Start("docker",
new[]
{
"run",
"--network", "none",
"--read-only",
"--mount", $"type=bind,src={testSolution.DirectoryFullPath},dst=/solution",
"--mount", $"type=bind,src={testSolution.DirectoryFullPath},dst=/output",
"--mount", "type=tmpfs,dst=/tmp",
"exercism/csharp-test-runner",
testSolution.Slug,
"/solution",
"/output"
})!.WaitForExit();

private static void RunTestRunnerWithoutDocker(TestSolution testSolution) =>
private static void RunTestRunner(TestSolution testSolution) =>
Program.Main(new[] { testSolution.Slug, testSolution.DirectoryFullPath, testSolution.DirectoryFullPath });

private static TestRun CreateTestRun(TestSolution solution)
Expand Down

0 comments on commit 2de5e25

Please sign in to comment.