From 01308e67e20602806545443335c8dbcfb40a0cb2 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Sun, 20 Oct 2024 14:44:57 +0200 Subject: [PATCH] MOre tweak --- bin/test.ps1 | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/bin/test.ps1 b/bin/test.ps1 index 9cb30afbd..960386a1a 100644 --- a/bin/test.ps1 +++ b/bin/test.ps1 @@ -55,7 +55,7 @@ function Add-Packages-ExerciseImplementation($PracticeExercisesDir) { function Test-Refactoring-Projects($PracticeExercisesDir) { Write-Output "Testing refactoring projects" @("tree-building", "ledger", "markdown") | ForEach-Object { - Invoke-Tests -Path "$PracticeExercisesDir/$_" + dotnet test "${PracticeExercisesDir}/${_}" } } @@ -63,9 +63,9 @@ function Set-ExampleImplementation { [CmdletBinding(SupportsShouldProcess)] param($ExercisesDir, $ReplaceFileName) - if ($PSCmdlet.ShouldProcess("Exercise $ReplaceFileName", "replace solution with example")) { + if ($PSCmdlet.ShouldProcess("Exercise ${ReplaceFileName}", "replace solution with example")) { Get-ChildItem -Path $ExercisesDir -Include "*.fsproj" -Recurse | ForEach-Object { - $stub = Join-Path -Path $_.Directory ($_.BaseName + ".fs") + $stub = Join-Path -Path $_.Directory ($_.BaseName + ".cs") $example = Join-Path -Path $_.Directory ".meta" $ReplaceFileName Move-Item -Path $example -Destination $stub -Force @@ -86,41 +86,27 @@ function Use-ExampleImplementation { } } -function Test-ExerciseImplementation($Exercise, $BuildDir, $ConceptExercisesDir, $PracticeExercisesDir, $IsCI) { +function Test-ExerciseImplementation($Exercise, $BuildDir, $ConceptExercisesDir, $PracticeExercisesDir) { Write-Output "Running tests" if (-Not $Exercise) { - Invoke-Tests -Path $BuildDir -IsCI $IsCI + dotnet test $BuildDir } - elseif (Test-Path "$ConceptExercisesDir/$Exercise") { - Invoke-Tests -Path "$ConceptExercisesDir/$Exercise" -IsCI $IsCI + elseif (Test-Path "${ConceptExercisesDir}/${Exercise}") { + dotnet test "${ConceptExercisesDir}/${Exercise}" } - elseif (Test-Path "$PracticeExercisesDir/$Exercise") { - Invoke-Tests -Path "$PracticeExercisesDir/$Exercise" -IsCI $IsCI + elseif (Test-Path "${PracticeExercisesDir}/${Exercise}") { + dotnet test "${PracticeExercisesDir}/${Exercise}" } else { - throw "Could not find exercise '$Exercise'" + throw "Could not find exercise '${Exercise}'" } } -function Invoke-Tests($Path, $IsCI) { - if ($IsCI) { - Get-ChildItem -Path $Path -Include "*.fsproj" -Recurse | ForEach-Object { - & dotnet add $_.FullName package JunitXml.TestLogger -n -v 3.0.134 - } - & dotnet test $Path --logger "junit;LogFilePath=results/test.xml" - } - else { - & dotnet test "$Path" - } -} - - -$buildDir = Join-Path $PSScriptRoot "build" -$practiceExercisesDir = Join-Path $buildDir "practice" -$conceptExercisesDir = Join-Path $buildDir "concept" +$buildDir = "${PSScriptRoot}/build" +$practiceExercisesDir = "${buildDir}/practice" +$conceptExercisesDir = "${buildDir}/concept" $sourceDir = Resolve-Path "exercises" -$isCi = [System.Convert]::ToBoolean($env:CI) Clean $buildDir Copy-Exercise $sourceDir $buildDir @@ -133,4 +119,4 @@ if (!$Exercise) { Use-ExampleImplementation $conceptExercisesDir $practiceExercisesDir Add-Packages-ExerciseImplementation -PracticeExercisesDir $practiceExercisesDir -Test-ExerciseImplementation -Exercise $Exercise -BuildDir $buildDir -ConceptExercisesDir $conceptExercisesDir -PracticeExercisesDir $practiceExercisesDir -IsCI $isCi +Test-ExerciseImplementation -Exercise $Exercise -BuildDir $buildDir -ConceptExercisesDir $conceptExercisesDir -PracticeExercisesDir $practiceExercisesDir