@@ -25,9 +25,20 @@ function freshTempDir(testCase)
25
25
' jobCommand' , command );
26
26
end
27
27
28
+ function [job , intValue , outputFile ] = multiPartCommandJob(testCase )
29
+ intValue = randi(1e9 );
30
+ outputFile = fullfile(testCase .tempDir , ' integerSaverJob.mat' );
31
+ command = { ...
32
+ sprintf(' evalin('' base'' , '' intValue=%d'' );' , intValue ), ...
33
+ sprintf(' evalin('' base'' , '' save(''''%s'''' )'' , '' intValue'' );' , outputFile )};
34
+ job = mjsJob( ...
35
+ ' name' , ' multiPartCommandJob' , ...
36
+ ' jobCommand' , command );
37
+ end
38
+
28
39
function [job , errorMessage ] = errorJob(testCase )
29
40
errorMessage = ' This is a test error.' ;
30
- command = {@ error , errorMessage } ;
41
+ command = sprintf( ' error( ''%s'' ) ' , errorMessage ) ;
31
42
job = mjsJob( ...
32
43
' name' , ' errorJob' , ...
33
44
' jobCommand' , command );
@@ -55,6 +66,16 @@ function testInDockerSuccess(testCase)
55
66
testCase .assertEqual(jobOutput .intValue , intValue );
56
67
end
57
68
69
+ function testMultiPartCommandSuccess(testCase )
70
+ [job , intValue , outputFile ] = testCase .multiPartCommandJob();
71
+ mjsExecuteLocal(job , ...
72
+ ' scriptFile' , fullfile(testCase .tempDir , ' scripts' , [job .name ' .sh' ]), ...
73
+ ' outputDir' , testCase .tempDir );
74
+ testCase .assertEqual(exist(outputFile , ' file' ), 2 );
75
+ jobOutput = load(outputFile );
76
+ testCase .assertEqual(jobOutput .intValue , intValue );
77
+ end
78
+
58
79
function testInMatlabError(testCase )
59
80
errorMessage = ' no error' ;
60
81
[job , expectedMessage ] = testCase .errorJob();
@@ -91,7 +112,7 @@ function testInDockerInputFolderPathError(testCase)
91
112
% "forget" to add the input folder that contains the function
92
113
job = mjsJob( ...
93
114
' name' , ' forgotInputDir' , ...
94
- ' jobCommand' , {@ deepTestFunction } );
115
+ ' jobCommand' , ' deepTestFunction' );
95
116
status = mjsExecuteLocal(job , ...
96
117
' scriptFile' , fullfile(testCase .tempDir , ' scripts' , [job .name ' .sh' ]), ...
97
118
' outputDir' , testCase .tempDir );
@@ -113,7 +134,7 @@ function testInDockerInputFolderPathSuccess(testCase)
113
134
% "remember" to add the input folder that contains the function
114
135
job = mjsJob( ...
115
136
' name' , ' rememberedInputDir' , ...
116
- ' jobCommand' , {@ deepTestFunction } );
137
+ ' jobCommand' , ' deepTestFunction' );
117
138
[status , result ] = mjsExecuteLocal(job , ...
118
139
' scriptFile' , fullfile(testCase .tempDir , ' scripts' , [job .name ' .sh' ]), ...
119
140
' inputDir' , inputDir , ...
@@ -155,7 +176,7 @@ function testInDockerWithCommonToolbox(testCase)
155
176
156
177
% make a job that uses the same toolbox
157
178
job = testCase .integerSaverJob();
158
- job.toolboxCommand = {@ tbUse , ' sample-repo' } ;
179
+ job.toolboxCommand = ' tbUse( '' sample-repo'' ) ' ;
159
180
160
181
% run the job with the shared toolbox folder mapped in
161
182
[status , result ] = mjsExecuteLocal(job , ...
@@ -179,7 +200,7 @@ function testOutputOwner(testCase)
179
200
' outputDir' , testCase .tempDir , ...
180
201
' outputOwner' , ' current' );
181
202
testCase .assertEqual(status , 0 );
182
-
203
+
183
204
% output file should contain expected data
184
205
testCase .assertEqual(exist(outputFile , ' file' ), 2 );
185
206
jobOutput = load(outputFile );
0 commit comments