-
Notifications
You must be signed in to change notification settings - Fork 2
/
TestRunner.cfm
44 lines (37 loc) · 1.28 KB
/
TestRunner.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<cfsilent>
<!---
Runs TestBox test and outputs in Codewars format.
To use, run:
box -clishellpath=/path/to/TestRunner.cfm
--->
<cfscript>
// Bootstrap TestBox framework
currentDir = getDirectoryFrompath( getCurrentTemplatePath());
createMapping( '/testbox', currentDir & 'testbox' );
createMapping( '/codewarsRoot', currentDir );
// Create TestBox and run the tests
testData = new testbox.system.TestBox( options={ coverage : { enabled : false } } )
.runRaw(
directory = {
// Find all CFCs in this directory that ends with Test.
mapping : '/codewarsRoot',
recurse : false,
filter = function( path ){
return path.reFindNoCase( "Test\.cfc$" );
}
}
)
.getMemento( includeDebugBuffer=true );
new CodewarsReporter().render( testData );
// Set exit code to 1 on failure
if ( testData.totalFail || testData.totalError ) {
createObject( 'java', 'java.lang.System' ).setProperty( 'cfml.cli.exitCode', 1 );
}
function createMapping( mappingName, mappingPath ) {
var mappings = getApplicationSettings().mappings;
if( !structKeyExists( mappings, mappingName ) || mappings[ mappingName ] != mappingPath ) {
mappings[ mappingName ] = mappingPath;
application action='update' mappings='#mappings#';
}
}
</cfscript></cfsilent>