@@ -34,7 +34,10 @@ public function setUp()
34
34
if (!isset ($ this ->kwBatchmakeComponent ))
35
35
{
36
36
require_once BASE_PATH .'/modules/batchmake/controllers/components/KWBatchmakeComponent.php ' ;
37
- $ this ->kwBatchmakeComponent = new Batchmake_KWBatchmakeComponent ($ this ->setupAndGetConfig ());
37
+ require_once BASE_PATH .'/modules/batchmake/tests/library/ExecutorMock.php ' ;
38
+ $ executor = new Batchmake_ExecutorMock ();
39
+ $ this ->kwBatchmakeComponent = new Batchmake_KWBatchmakeComponent ($ this ->setupAndGetConfig (), $ executor );
40
+ // $this->kwBatchmakeComponent = new Batchmake_KWBatchmakeComponent($this->setupAndGetConfig());
38
41
}
39
42
}
40
43
@@ -61,7 +64,7 @@ public function testGetBatchmakeScripts()
61
64
{
62
65
$ foundTestScripts = $ this ->kwBatchmakeComponent ->getBatchmakeScripts ();
63
66
sort ($ foundTestScripts );
64
- $ expectedTestScripts = array ("Compiles.bms " , "Myscript2.bms " , "noscripts.bms " ,
67
+ $ expectedTestScripts = array ("CompileEmptyOutput.bms " , " CompileReturnNonzero.bms " , " Compiles.bms " , "Myscript2.bms " , "noscripts.bms " ,
65
68
"anotherscript.bms " , "anotherscriptwitherrors.bms " , "bmmswitherrors.bms " ,
66
69
"cycle1.bms " , "cycle31.bms " , "cycle32.bms " , "cycle33.bms " , "nocycle1.bms " ,
67
70
"nocycle2.bms " , "nocycle3.bms " , "myscript.bms " , "PixelCounter.bms " ,
@@ -232,9 +235,6 @@ public function testPreparePipelineBmms()
232
235
233
236
234
237
235
-
236
-
237
-
238
238
/** tests testCompileBatchMakeScript */
239
239
public function testCompileBatchMakeScript ()
240
240
{
@@ -250,7 +250,7 @@ public function testCompileBatchMakeScript()
250
250
// this one should work
251
251
$ this ->kwBatchmakeComponent ->compileBatchMakeScript ($ workDir , $ scriptName );
252
252
253
- // now try a script that doesn't compile
253
+ // now try a script that doesn't compile but returns errors
254
254
$ scriptName = 'CompileErrors.bms ' ;
255
255
$ bmScripts = $ this ->kwBatchmakeComponent ->preparePipelineScripts ($ workDir , $ scriptName );
256
256
$ bmms = $ this ->kwBatchmakeComponent ->preparePipelineBmms ($ workDir , $ bmScripts );
@@ -262,7 +262,41 @@ public function testCompileBatchMakeScript()
262
262
catch (Zend_Exception $ ze )
263
263
{
264
264
// if we got here, this is the correct behavior
265
- $ this ->assertTrue (true );
265
+ // check that the exception came from the right place
266
+ $ this ->assertEquals (1 , preg_match ('/compileBatchMakeScript/ ' , $ ze ->getMessage ()));
267
+ }
268
+
269
+ // now try a script that returns a non-zero value from the compile step
270
+ $ scriptName = 'CompileReturnNonzero.bms ' ;
271
+ $ bmScripts = $ this ->kwBatchmakeComponent ->preparePipelineScripts ($ workDir , $ scriptName );
272
+ $ bmms = $ this ->kwBatchmakeComponent ->preparePipelineBmms ($ workDir , $ bmScripts );
273
+ try
274
+ {
275
+ $ this ->kwBatchmakeComponent ->compileBatchMakeScript ($ workDir , $ scriptName );
276
+ $ this ->fail ('Should have had a compile error but did not, testCompileBatchMakeScript ' );
277
+ }
278
+ catch (Zend_Exception $ ze )
279
+ {
280
+ // if we got here, this is the correct behavior
281
+ // check that the exception came from the right place
282
+ $ this ->assertEquals (1 , preg_match ('/compileBatchMakeScript/ ' , $ ze ->getMessage ()));
283
+ }
284
+
285
+
286
+ //a script that returns a zero value but an empty output from the compile step
287
+ $ scriptName = 'CompileEmptyOutput.bms ' ;
288
+ $ bmScripts = $ this ->kwBatchmakeComponent ->preparePipelineScripts ($ workDir , $ scriptName );
289
+ $ bmms = $ this ->kwBatchmakeComponent ->preparePipelineBmms ($ workDir , $ bmScripts );
290
+ try
291
+ {
292
+ $ this ->kwBatchmakeComponent ->compileBatchMakeScript ($ workDir , $ scriptName );
293
+ $ this ->fail ('Should have had a compile error but did not, testCompileBatchMakeScript ' );
294
+ }
295
+ catch (Zend_Exception $ ze )
296
+ {
297
+ // if we got here, this is the correct behavior
298
+ // check that the exception came from the right place
299
+ $ this ->assertEquals (1 , preg_match ('/compileBatchMakeScript/ ' , $ ze ->getMessage ()));
266
300
}
267
301
268
302
}
@@ -274,27 +308,36 @@ public function testGenerateCondorDag()
274
308
$ userDao = $ this ->User ->load ($ usersFile [0 ]->getKey ());
275
309
$ workDir = $ this ->kwBatchmakeComponent ->createTask ($ userDao );
276
310
311
+ // try a script that returns a non-zero value
312
+ $ scriptName = 'CompileReturnNonzero.bms ' ;
313
+ $ bmScripts = $ this ->kwBatchmakeComponent ->preparePipelineScripts ($ workDir , $ scriptName );
314
+ $ bmms = $ this ->kwBatchmakeComponent ->preparePipelineBmms ($ workDir , $ bmScripts );
315
+ try
316
+ {
317
+ $ dagJobFile = $ this ->kwBatchmakeComponent ->generateCondorDag ($ workDir , $ scriptName );
318
+ $ this ->fail ('Should have had an error but did not, testGenerateCondorDag ' );
319
+ }
320
+ catch (Zend_Exception $ ze )
321
+ {
322
+ // if we got here, this is the correct behavior
323
+ // check that the exception came from the right place
324
+ $ this ->assertEquals (1 , preg_match ('/generateCondorDag/ ' , $ ze ->getMessage ()));
325
+ }
326
+
277
327
// a script that compiles
278
328
$ scriptName = 'Compiles.bms ' ;
279
329
$ bmScripts = $ this ->kwBatchmakeComponent ->preparePipelineScripts ($ workDir , $ scriptName );
280
330
$ bmms = $ this ->kwBatchmakeComponent ->preparePipelineBmms ($ workDir , $ bmScripts );
281
331
282
332
// try to generate the Condor script
283
333
$ dagJobFile = $ this ->kwBatchmakeComponent ->generateCondorDag ($ workDir , $ scriptName );
284
- $ this ->assertEquals ($ dagJobFile , 'Compiles.bms. dagjob ' );
334
+ $ this ->assertEquals ($ dagJobFile , 'Compiles.dagjob ' );
285
335
// check that dag files and condor job files were created
286
- $ condorFiles = array ($ dagJobFile , 'Compiles.1.bms. dagjob ' , 'Compiles.3.bms. dagjob ' , 'Compiles.5.bms .dagjob ' );
336
+ $ condorFiles = array ($ dagJobFile , 'Compiles.1.dagjob ' , 'Compiles.3.dagjob ' , 'Compiles.5.dagjob ' );
287
337
foreach ($ condorFiles as $ condorFile )
288
338
{
289
339
$ this ->assertFileExists ($ workDir .'/ ' .$ condorFile );
290
340
}
291
- // now look for some specific strings
292
- $ contents = file_get_contents ($ workDir .'/ ' . 'Compiles.bms.dagjob ' );
293
- $ dagjobStrings = array ('Job job3 ' , 'Job job5 ' , 'PARENT job1 CHILD job3 ' , 'PARENT job3 CHILD job5 ' );
294
- foreach ($ dagjobStrings as $ string )
295
- {
296
- $ this ->assertTrue (preg_match ("/ " .$ string ."/ " , $ contents , $ matches ) === 1 );
297
- }
298
341
}
299
342
300
343
@@ -305,6 +348,20 @@ public function testCondorSubmitDag()
305
348
$ userDao = $ this ->User ->load ($ usersFile [0 ]->getKey ());
306
349
$ workDir = $ this ->kwBatchmakeComponent ->createTask ($ userDao );
307
350
351
+ // try a script that returns a non-zero value
352
+ $ scriptName = 'CompileReturnNonzero.dagjob ' ;
353
+ try
354
+ {
355
+ $ this ->kwBatchmakeComponent ->condorSubmitDag ($ workDir , $ scriptName );
356
+ $ this ->fail ('Should have had an error but did not, testCondorSubmitDag ' );
357
+ }
358
+ catch (Zend_Exception $ ze )
359
+ {
360
+ // if we got here, this is the correct behavior
361
+ // check that the exception came from the right place
362
+ $ this ->assertEquals (1 , preg_match ('/condorSubmitDag/ ' , $ ze ->getMessage ()));
363
+ }
364
+
308
365
// a script that compiles
309
366
$ scriptName = 'Compiles.bms ' ;
310
367
$ bmScripts = $ this ->kwBatchmakeComponent ->preparePipelineScripts ($ workDir , $ scriptName );
@@ -313,6 +370,9 @@ public function testCondorSubmitDag()
313
370
$ dagScript = $ this ->kwBatchmakeComponent ->generateCondorDag ($ workDir , $ scriptName );
314
371
$ this ->kwBatchmakeComponent ->condorSubmitDag ($ workDir , $ dagScript );
315
372
// how to check this now?
373
+ // TODO think about this some more
374
+ // perhaps send something back through the web-api
375
+ // what would that be testing exactly?
316
376
}
317
377
318
378
0 commit comments