-
Notifications
You must be signed in to change notification settings - Fork 0
/
BaseRunner.cfc
79 lines (63 loc) · 2.6 KB
/
BaseRunner.cfc
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
component {
property name='CommandService' inject;
param startAJP = false;
function run( boolean skipServer=false ) {
param variables.fixtures = {};
fixtures.each( ( testName, t )=>{
print.line( testName ).toConsole();
runTests( t.serverConfigFile, t.env ?: {}, skipServer );
} );
}
function runTests( required string serverConfigFile, struct env={}, boolean skipServer=false ) {
// Running resolvePath() inside the clsoure below will resolve to the wrong path since the closure executes inside the CommandService
var testboxPath = resolvePath( getDirectoryFromPath( serverConfigFile ) & "/../testbox/" );
var specsPath = resolvePath( getDirectoryFromPath( serverConfigFile ) & "/tests/specs" );
// run in a "sub-shell" so we can load env vars via dot env which only apply to this site
CommandService.runInEnvironment(
'runTests',
()=>{
systemSettings.setSystemSettings( env );
systemSettings.setSystemSetting( 'box_server_openBrowser', false )
systemSettings.setSystemSetting( 'box_server_fusionreactor_enable', false )
try {
if( !skipServer ) {
print.line( 'Starting Server [#serverConfigFile#]' ).toConsole();
command( 'server start' )
.params( serverConfigFile=serverConfigFile )
.flags( 'verbose' )
.run( returnOutput=true );
sleep( 2000 )
}
fileSystemUtil.createMapping( '/testbox', testboxPath )
var testbox = new testbox.system.TestBox( options = { coverage : { enabled : false } } );
testbox.addDirectories( fileSystemUtil.makePathRelative( specsPath ) );
var results = deserializeJSON( testbox.run( reporter="JSON" ) );
getInstance( "CLIRenderer@testbox-cli" ).render( print, results, true )
print.toConsole()
} finally {
if( !skipServer ) {
print.line( 'Stopping Server [#serverConfigFile#]' ).toConsole();
command( 'server stop' )
.params( serverConfigFile=serverConfigFile )
.run( returnOutput=true );
sleep( 5000 )
}
}
}
);
}
function preRun() {
if( !startAJP || (taskArgs.skipServer ?: false) ) return;
print.line( 'Starting Docker AJP Proxy' ).toConsole();
command( 'server run-script ajp-up' )
.inWorkingDirectory( resolvePath( getDirectoryFromPath( getCurrentTemplatePath() ) & "../" ) )
.run( returnOutput=true );
}
function postRun() {
if( !startAJP || (taskArgs.skipServer ?: false) ) return;
print.line( 'Stopping Docker AJP Proxy' ).toConsole();
command( 'server run-script ajp-down' )
.inWorkingDirectory( resolvePath( getDirectoryFromPath( getCurrentTemplatePath() ) & "../" ) )
.run( returnOutput=true );
}
}