86 %LET l_macname=&sysmacroname;
88 %_sasunit_tempFileName(d_dir);
89 %_sasunit_tempFileName(d_examinee);
92 %IF %_sasunit_handleError(&l_macname, NoTestDB,
93 NOT %sysfunc(exist(target.tsu)) OR NOT %symexist(g_project),
94 %nrstr(test database cannot be accessed, call %initSASUnit before %runSASUnit))
98 %IF
"&i_recursive" NE
"1" %THEN %LET i_recursive=0;
101 %LET l_source = %_sasunit_abspath(&g_root, &i_source);
102 %_sasunit_dir(i_path=&l_source, i_recursive=&i_recursive, o_out=&d_dir)
103 %IF %_sasunit_handleError(&l_macname, NoSourceFiles,
104 %_sasunit_nobs(&d_dir) EQ 0,
105 Error in parameter i_source: no test scenarios found)
108 %DO i=1 %TO %_sasunit_nobs(&d_dir);
117 CALL symput (
'l_scnfile' !! left(put(_n_,8.)), trim(filename));
118 CALL symput (
'l_scnchanged' !! left(put(_n_,8.)), compress(put(changed,12.)));
119 CALL symput (
'l_nscn', compress(put(_n_,8.)));
123 %LET l_auto=&g_sasautos;
125 %DO %WHILE(
"&l_auto" ne
"");
126 %LET l_auto=%quote(&l_auto/);
127 %_sasunit_dir(i_path=&l_auto.*.sas, o_out=&d_dir)
129 set %IF &l_autonr>0 %THEN &d_examinee; &d_dir(in=indir);
130 if indir then auton=&l_autonr;
132 %LET l_autonr = %eval(&l_autonr+1);
134 %IF %symexist(g_sasautos&l_autonr) %THEN %LET l_auto=&&g_sasautos&l_autonr;
140 %LET l_scn = %_sasunit_stdPath(&g_root, &&l_scnfile&i);
143 %_sasunit_checkScenario(
144 i_scnfile = &&l_scnfile&i
145 ,i_changed = &&l_scnchanged&i
152 %IF &l_scnid = 0 %THEN %DO;
154 SELECT max(scn_id) INTO :l_scnid FROM target.scn;
155 %IF &l_scnid=. %THEN %LET l_scnid=0;
156 %LET l_scnid = %eval(&l_scnid+1);
157 INSERT INTO target.scn VALUES (
165 %ELSE %IF &l_dorun %THEN %DO;
167 DELETE FROM target.cas WHERE cas_scnid = &l_scnid;
168 DELETE FROM target.tst WHERE tst_scnid = &l_scnid;
172 %IF &l_dorun %THEN %DO;
173 %PUT ======== test scenario &l_scnid (&l_scn) will be run ========;
178 %PUT ======== test scenario &l_scnid (&l_scn) will not be run ==;
184 %IF &l_dorun %THEN %DO;
187 %_sasunit_getPgmDesc (i_pgmfile=&&l_scnfile&i, r_desc=l_scndesc)
189 UPDATE target.scn SET
190 scn_desc = "&l_scndesc"
191 ,scn_start = %sysfunc(datetime())
192 WHERE scn_id = &l_scnid
198 FILE "%sysfunc(pathname(work))/x.cmd";
199 PUT "&g_removedir ""%sysfunc(pathname(work))/sasuser""&g_endcommand";
200 PUT "&g_makedir ""%sysfunc(pathname(work))/sasuser""&g_endcommand";
201 %IF %length(&g_sasuser) %THEN %DO;
202 PUT "&g_copydir ""&g_sasuser"" ""%sysfunc(pathname(work))/sasuser""&g_endcommand";
205 %if &sysscp. = LINUX %then %do;
206 %_sasunit_xcmd(chmod u+x "%sysfunc(pathname(work))/x.cmd")
208 %_sasunit_xcmd("%sysfunc(pathname(work))/x.cmd")
209 %LET l_rc=_sasunit_delfile(%sysfunc(pathname(work))/x.cmd);
213 %LET l_parenthesis=(;
214 %IF "&g_autoexec" NE "" %THEN %DO;
215 %LET l_parms=&l_parms -autoexec ""&g_autoexec"";
217 %IF &sysscp. = LINUX %THEN %DO;
218 %IF "&g_sascfg" NE "" %THEN %DO;
219 options SET=SASCFGPATH "&g_sascfg.";
223 %IF "&g_sascfg" NE "" %THEN %DO;
224 %LET l_parms=&l_parms -config ""&g_sascfg"";
226 %ELSE %IF %length(%sysfunc(getoption(config))) NE 0 AND %index(%quote(%sysfunc(getoption(config))),%bquote(&l_parenthesis)) NE 1 %THEN %DO;
227 %LET l_parms=&l_parms -config ""%sysfunc(getoption(config))"";
231 %LET l_scnlogfullpath = &g_log/%substr(00&l_scnid.,%length(&l_scnid)).log;
235 _sCmdString LENGTH = $32000
238 "%sysfunc(pathname(work))/xx.cmd"
241 %IF &sysscp. = LINUX %THEN %DO;
246 !! "-sysin &&l_scnfile&i "
247 !! "-initstmt ""%nrstr(%%_sasunit_scenario%(io_target=)&g_target%nrstr(%);%%let g_scnid=)&l_scnid.;"" "
248 !! "-log &l_scnlogfullpath. "
249 !! "-print &g_testout/%substr(00&l_scnid.,%length(&l_scnid)).lst "
253 !! "-mcompilenote all "
254 !! "-sasautos &g_sasunit "
255 !! "-sasuser %sysfunc(pathname(work))/sasuser "
256 !! "-termstmt ""%nrstr(%%_sasunit_termScenario())"" "
261 """" !! &g_sasstart !! """"
264 !! "-sysin ""&&l_scnfile&i"" "
265 !! "-initstmt ""%nrstr(%%%_sasunit_scenario%(io_target=)&g_target%nrstr(%);%%%let g_scnid=)&l_scnid.;"" "
266 !! "-log ""&l_scnlogfullpath."" "
267 !! "-print ""&g_testout/%substr(00&l_scnid.,%length(&l_scnid)).lst"" "
272 !! "-mcompilenote all "
273 !! "-sasautos ""&g_sasunit"" "
274 !! "-sasuser ""%sysfunc(pathname(work))/sasuser"" "
275 !! "-termstmt ""%nrstr(%%%_sasunit_termScenario())"" "
282 %IF &sysscp. = LINUX %THEN %DO;
283 %_sasunit_xcmd(chmod u+x "%sysfunc(pathname(work))/xx.cmd");
284 %_sasunit_xcmd(sed -i -e 's/\r
286 %_sasunit_xcmd("%sysfunc(pathname(work))/xx.cmd")
289 %LET l_rc=_sasunit_delfile(%sysfunc(pathname(work))/xx.cmd);
290 %LET l_sysrc = &sysrc;
294 FILE "%sysfunc(pathname(work))/x.cmd";
295 PUT "&g_removedir ""%sysfunc(pathname(work))/sasuser""&g_endcommand";
297 %if &sysscp. = LINUX %then %do;
298 %_sasunit_xcmd(chmod u+x "%sysfunc(pathname(work))/x.cmd")
301 %_sasunit_xcmd("%sysfunc(pathname(work))/x.cmd")
302 %LET l_rc=_sasunit_delfile(%sysfunc(pathname(work))/x.cmd);
306 %LET l_lstfile=&g_testout/%substr(00&l_scnid,%length(&l_scnid)).lst;
307 %IF %SYSFUNC(FILEEXIST("&l_lstfile")) %THEN %DO;
311 CALL symput ('l_filled','1');
315 %IF NOT &l_filled %THEN %DO;
316 %LET l_filled=%_sasunit_delfile(&l_lstfile);
322 i_logfile = &l_scnlogfullpath.
324 ,i_warning = &g_warning.
325 ,r_errors = l_error_count
326 ,r_warnings= l_warning_count
331 SELECT count(*) INTO :l_result0 FROM target.cas WHERE cas_scnid=&l_scnid AND cas_res=0;
332 SELECT count(*) INTO :l_result1 FROM target.cas WHERE cas_scnid=&l_scnid AND cas_res=1;
333 SELECT count(*) INTO :l_result2 FROM target.cas WHERE cas_scnid=&l_scnid AND cas_res=2;
335 %IF &l_result1 GT 0 %THEN %DO;
338 %ELSE %IF &l_result2 GT 0 %THEN %DO;
341 %ELSE %IF %EVAL(%SYSFUNC(sum(&l_result0., &l_result1., &l_result2.)) EQ 0) %THEN %DO;
344 %ELSE %IF &l_error_count. GT 0 %THEN %DO;
353 scn_end = %sysfunc(datetime())
355 ,scn_errorcount = &l_error_count.
356 ,scn_warningcount = &l_warning_count.
357 ,scn_res = &l_result.
369 %PUT =========================== Error! runSASUnit aborted! ==========================================;
373 %IF %EVAL("%UPCASE(&g_error_code.)" EQ "%UPCASE(NoSourceFiles)") %THEN %DO;
377 %LET l_scn = %_sasunit_stdPath(&g_root., &l_source.);
379 %LET l_nscncount = 0;
382 INTO :l_nscncount SEPARATED BY ''
384 WHERE Upcase(scn_path) = "%UPCASE(&l_scn.)";
387 %IF %EVAL(&l_nscncount. EQ 0) %THEN %DO;
389 %LET l_scndesc = %STR(Scenario not found - has to fail!);
392 SELECT max(scn_id) INTO :l_scnid FROM target.scn;
393 %IF &l_scnid=. %THEN %LET l_scnid=0;
394 %LET l_scnid = %eval(&l_scnid+1);
395 INSERT INTO target.scn
427 PROC DATASETS NOLIST NOWARN LIB=%scan(&d_dir,1,.);
428 DELETE %scan(&d_dir,2,.);
429 DELETE %scan(&d_examinee,2,.);