Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions exercises/practice/acronym/TestRunner.bxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() );
localTestBox = exerciseDir & "testbox";
hiddenTestBox = exerciseDir & ".testbox_cfml";
testBoxWasHidden = false;
exitCode = 0;

try {
// CommandBox installs its CFML TestBox dependency here. Hide it while the
// BoxLang module is running so both local test runners can coexist.
if( directoryExists( localTestBox ) ) {
if( directoryExists( hiddenTestBox ) ) {
throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." );
}
directoryRename( localTestBox, hiddenTestBox );
testBoxWasHidden = true;
}

testBox = new testbox.system.TestBox( reporter = "console" );
testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" );
if( !testFiles.len() ) {
throw( message = "No test files found in " & exerciseDir );
}

for( file in testFiles ) {
testBox.addBundles( "exercise." & file.listFirst( "." ) );
}

results = testBox.runRaw();
new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true );

if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) {
exitCode = 1;
}
} catch( any e ) {
println( "ERROR: " & e.message );
if( len( e.detail ?: "" ) ) {
println( e.detail );
}
exitCode = 1;
} finally {
if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) {
directoryRename( hiddenTestBox, localTestBox );
}
}

CLIExit( exitCode );
6 changes: 6 additions & 0 deletions exercises/practice/acronym/boxlang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"mappings": {
"/testbox": "${user-home}/.boxlang/modules/testbox",
"/exercise": "${user-dir}"
}
}
37 changes: 0 additions & 37 deletions exercises/practice/acronym/index.cfm

This file was deleted.

46 changes: 46 additions & 0 deletions exercises/practice/all-your-base/TestRunner.bxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() );
localTestBox = exerciseDir & "testbox";
hiddenTestBox = exerciseDir & ".testbox_cfml";
testBoxWasHidden = false;
exitCode = 0;

try {
// CommandBox installs its CFML TestBox dependency here. Hide it while the
// BoxLang module is running so both local test runners can coexist.
if( directoryExists( localTestBox ) ) {
if( directoryExists( hiddenTestBox ) ) {
throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." );
}
directoryRename( localTestBox, hiddenTestBox );
testBoxWasHidden = true;
}

testBox = new testbox.system.TestBox( reporter = "console" );
testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" );
if( !testFiles.len() ) {
throw( message = "No test files found in " & exerciseDir );
}

for( file in testFiles ) {
testBox.addBundles( "exercise." & file.listFirst( "." ) );
}

results = testBox.runRaw();
new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true );

if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) {
exitCode = 1;
}
} catch( any e ) {
println( "ERROR: " & e.message );
if( len( e.detail ?: "" ) ) {
println( e.detail );
}
exitCode = 1;
} finally {
if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) {
directoryRename( hiddenTestBox, localTestBox );
}
}

CLIExit( exitCode );
6 changes: 6 additions & 0 deletions exercises/practice/all-your-base/boxlang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"mappings": {
"/testbox": "${user-home}/.boxlang/modules/testbox",
"/exercise": "${user-dir}"
}
}
37 changes: 0 additions & 37 deletions exercises/practice/all-your-base/index.cfm

This file was deleted.

46 changes: 46 additions & 0 deletions exercises/practice/allergies/TestRunner.bxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() );
localTestBox = exerciseDir & "testbox";
hiddenTestBox = exerciseDir & ".testbox_cfml";
testBoxWasHidden = false;
exitCode = 0;

try {
// CommandBox installs its CFML TestBox dependency here. Hide it while the
// BoxLang module is running so both local test runners can coexist.
if( directoryExists( localTestBox ) ) {
if( directoryExists( hiddenTestBox ) ) {
throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." );
}
directoryRename( localTestBox, hiddenTestBox );
testBoxWasHidden = true;
}

testBox = new testbox.system.TestBox( reporter = "console" );
testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" );
if( !testFiles.len() ) {
throw( message = "No test files found in " & exerciseDir );
}

for( file in testFiles ) {
testBox.addBundles( "exercise." & file.listFirst( "." ) );
}

results = testBox.runRaw();
new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true );

if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) {
exitCode = 1;
}
} catch( any e ) {
println( "ERROR: " & e.message );
if( len( e.detail ?: "" ) ) {
println( e.detail );
}
exitCode = 1;
} finally {
if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) {
directoryRename( hiddenTestBox, localTestBox );
}
}

CLIExit( exitCode );
6 changes: 6 additions & 0 deletions exercises/practice/allergies/boxlang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"mappings": {
"/testbox": "${user-home}/.boxlang/modules/testbox",
"/exercise": "${user-dir}"
}
}
37 changes: 0 additions & 37 deletions exercises/practice/allergies/index.cfm

This file was deleted.

46 changes: 46 additions & 0 deletions exercises/practice/anagram/TestRunner.bxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() );
localTestBox = exerciseDir & "testbox";
hiddenTestBox = exerciseDir & ".testbox_cfml";
testBoxWasHidden = false;
exitCode = 0;

try {
// CommandBox installs its CFML TestBox dependency here. Hide it while the
// BoxLang module is running so both local test runners can coexist.
if( directoryExists( localTestBox ) ) {
if( directoryExists( hiddenTestBox ) ) {
throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." );
}
directoryRename( localTestBox, hiddenTestBox );
testBoxWasHidden = true;
}

testBox = new testbox.system.TestBox( reporter = "console" );
testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" );
if( !testFiles.len() ) {
throw( message = "No test files found in " & exerciseDir );
}

for( file in testFiles ) {
testBox.addBundles( "exercise." & file.listFirst( "." ) );
}

results = testBox.runRaw();
new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true );

if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) {
exitCode = 1;
}
} catch( any e ) {
println( "ERROR: " & e.message );
if( len( e.detail ?: "" ) ) {
println( e.detail );
}
exitCode = 1;
} finally {
if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) {
directoryRename( hiddenTestBox, localTestBox );
}
}

CLIExit( exitCode );
6 changes: 6 additions & 0 deletions exercises/practice/anagram/boxlang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"mappings": {
"/testbox": "${user-home}/.boxlang/modules/testbox",
"/exercise": "${user-dir}"
}
}
37 changes: 0 additions & 37 deletions exercises/practice/anagram/index.cfm

This file was deleted.

Loading
Loading