From 4522981f13b312a33e513d6139a89fcd049ed6fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20B=20Nagy?= <20251272+BNAndras@users.noreply.github.com> Date: Sun, 2 Aug 2026 11:37:00 -0700 Subject: [PATCH] Copy only specified exercise when requested --- bin/test.ps1 | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/bin/test.ps1 b/bin/test.ps1 index 9a4f1ef4..b2d8d1b2 100644 --- a/bin/test.ps1 +++ b/bin/test.ps1 @@ -30,11 +30,22 @@ function Clean($BuildDir) { Remove-Item -Recurse -Force $BuildDir -ErrorAction Ignore } -function Copy-Exercise($SourceDir, $BuildDir) { +function Copy-Exercises($SourceDir, $BuildDir) { Write-Output "Copying exercises" Copy-Item $SourceDir -Destination $BuildDir -Recurse } +function Copy-SingleExercise($SourceDir, $PracticeExercisesDir, $Exercise) { + $exerciseDir = Join-Path $SourceDir "practice" $Exercise + if (-Not (Test-Path $exerciseDir)) { + throw "Could not find exercise '$Exercise'" + } + + Write-Output "Copying $Exercise exercise" + New-Item -ItemType Directory -Force $PracticeExercisesDir | Out-Null + Copy-Item $exerciseDir -Destination $PracticeExercisesDir -Recurse +} + function Enable-All-UnitTests($BuildDir) { Write-Output "Enabling all tests" Get-ChildItem -Path $BuildDir -Include "*Tests.vb" -Recurse | ForEach-Object { @@ -61,7 +72,7 @@ function Use-ExampleImplementation { param($PracticeExercisesDir) if ($PSCmdlet.ShouldProcess("Exercises directory", "replace all solutions with corresponding examples")) { - Write-Output "Replacing practice exercise stubs with example" + Write-Output "Replacing practice exercise stub(s) with example" Set-ExampleImplementation $PracticeExercisesDir "Example.vb" } } @@ -87,7 +98,11 @@ $practiceExercisesDir = Join-Path $buildDir "practice" $sourceDir = Join-Path $repoRoot "exercises" Clean $buildDir -Copy-Exercise $sourceDir $buildDir +if ($Exercise) { + Copy-SingleExercise $sourceDir $practiceExercisesDir $Exercise +} else { + Copy-Exercises $sourceDir $buildDir +} Enable-All-UnitTests $buildDir Use-ExampleImplementation $practiceExercisesDir Test-ExerciseImplementation -Exercise $Exercise -BuildDir $buildDir -PracticeExercisesDir $practiceExercisesDir