From 3fea0adaeb25060259e77638329ac05aaafa5664 Mon Sep 17 00:00:00 2001 From: BNAndras <20251272+BNAndras@users.noreply.github.com> Date: Sun, 12 Apr 2026 22:02:56 -0700 Subject: [PATCH 1/4] Update CI to test all exercises --- tasks/TestAllSolutions.cfc | 105 ++++++++++++++++++++++++++++--------- 1 file changed, 80 insertions(+), 25 deletions(-) diff --git a/tasks/TestAllSolutions.cfc b/tasks/TestAllSolutions.cfc index c2b5373..fe47191 100644 --- a/tasks/TestAllSolutions.cfc +++ b/tasks/TestAllSolutions.cfc @@ -1,27 +1,82 @@ /** -* I test all the solutions in each exercise to make sure they all pass. -*/ + * I test all the example solutions to make sure they all pass. + */ component { - - function run() { - // Get an array of all the excercise names - var exercises = directoryList( expandPath( getDirectoryFromPath( getCurrentTemplatePath() ) & '../exercises' ) ); - var exitCode = 0; - - // If there's a testrunner task in them, run it. If any of the tasks fail, the exit code will come back as 1 - exercises.each( function( path ) { - if( fileExists( path & '/TestRunner.cfc' ) ) { - command( 'task run' ) - .params( 'TestRunner' ) - // Specifically as the task runners to run the SolutionTest - .flags( ':solution' ) - .inWorkingDirectory( path ) - .run(); - exitCode = max( exitCode, createObject( 'java', 'java.lang.System' ).getProperty( 'cfml.cli.exitCode' ) ?: 0 ); - } - } ); - - setExitCode( exitCode ); - } - -} \ No newline at end of file + + function run() { + // grab concept and practice exercises + var exercisesRoot = expandPath(getDirectoryFromPath(getCurrentTemplatePath()) & '../exercises'); + var exercises = []; + for (var exerciseType in ['practice', 'concept']) { + var exerciseDir = exercisesRoot & '/' & exerciseType; + if (directoryExists(exerciseDir)) { + exercises.append( + directoryList( + exerciseDir, + false, + 'path', + '', + 'name', + 'dir' + ), + true + ); + } + } + var exitCode = 0; + var count = 0; + + for (var path in exercises) { + if (!fileExists(path & '/TestRunner.cfc') || !fileExists(path & '/.meta/config.json')) { + continue; + } + + var slug = listLast(path, '/\'); + var pascalSlug = slug + .listToArray('-') + .map(function(w) { + return w.left(1).uCase() & w.mid(2, w.len()); + }) + .toList(''); + var stub = path & '/' & pascalSlug & '.cfc'; + var example = path & '/.meta/Example.cfc'; + var backup = fileRead(stub); + fileCopy(example, stub); + + print.line('#slug# - running').toConsole(); + + // suppress output for passing tests + var passed = false; + try { + command('task run') + .params('TestRunner') + .inWorkingDirectory(path) + .run(returnOutput = true); + passed = true; + } catch (any e) { + passed = false; + } + + fileWrite(stub, backup); + + count++; + + if (passed) { + print.line('#slug# - passed').toConsole(); + } else { + // rerun without capture to get failing output + command('task run') + .params('TestRunner') + .inWorkingDirectory(path) + .run(); + exitCode = 1; + break; + } + } + + print.line('Test suites run: #count#'); + + setExitCode(exitCode); + } + +} From dc9cebfc5dc3d2aa9f8ec60e3e30a6505ef16532 Mon Sep 17 00:00:00 2001 From: BNAndras <20251272+BNAndras@users.noreply.github.com> Date: Mon, 13 Apr 2026 21:39:52 -0700 Subject: [PATCH 2/4] Restore stub for failed exercises --- tasks/TestAllSolutions.cfc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tasks/TestAllSolutions.cfc b/tasks/TestAllSolutions.cfc index fe47191..022e021 100644 --- a/tasks/TestAllSolutions.cfc +++ b/tasks/TestAllSolutions.cfc @@ -57,18 +57,22 @@ component { passed = false; } - fileWrite(stub, backup); - count++; if (passed) { + fileWrite(stub, backup); print.line('#slug# - passed').toConsole(); } else { // rerun without capture to get failing output - command('task run') - .params('TestRunner') - .inWorkingDirectory(path) - .run(); + try { + command('task run') + .params('TestRunner') + .inWorkingDirectory(path) + .run(); + } catch (any e) { + passed = false; + } + fileWrite(stub, backup); exitCode = 1; break; } From fcd9c6f798276b6820f390532381f8d048978b4e Mon Sep 17 00:00:00 2001 From: BNAndras <20251272+BNAndras@users.noreply.github.com> Date: Mon, 13 Apr 2026 21:55:35 -0700 Subject: [PATCH 3/4] Fix caching CommandBox --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 73c3dba..af73476 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,8 @@ jobs: with: path: | $HOME/.CommandBox - key: commandbox-${{ runner.os }}-${{ hashFiles('**/*.box') }} + exercises/**/testbox + key: commandbox-${{ runner.os }}-${{ hashFiles('**/box.json') }} - name: Install CommandBox run: | From 1e7e5628e3604a8fa95fa6187f9127e1d70a59fd Mon Sep 17 00:00:00 2001 From: BNAndras <20251272+BNAndras@users.noreply.github.com> Date: Mon, 13 Apr 2026 21:57:24 -0700 Subject: [PATCH 4/4] Test cache