40 %MACRO runSASUnit(i_source =
80 %LET l_macname=&sysmacroname;
82 %_tempFileName(d_dependency);
83 %_tempFileName(d_dir);
84 %_tempFileName(d_examinee);
85 %_tempFileName(d_listcalling);
86 %_tempFileName(d_macroList);
87 %_tempFileName(d_scenariosToRun);
88 %_tempFileName(d_scn_pre);
91 %IF %_handleError(&l_macname.
93 ,NOT %sysfunc(exist(target.tsu)) OR NOT %symexist(g_project)
94 ,%nrstr(test database cannot be accessed, call initSASUnit before runSASUnit)
95 ,i_verbose=&g_verbose.
100 %IF
"&i_recursive" NE
"1" %THEN %LET i_recursive=0;
103 %LET l_source = %_abspath(&g_root, &i_source);
104 %_dir(i_path=&l_source, i_recursive=&i_recursive, o_out=&d_dir)
105 %IF %_handleError(&l_macname.
108 ,Error in parameter i_source: no test scenarios found
109 ,i_verbose=&g_verbose.
118 %LET l_auto=&g_sasautos;
120 %DO %WHILE(
"&l_auto" ne
"");
121 %LET l_auto=%quote(&l_auto/);
122 %_dir(i_path=&l_auto.*.sas, o_out=&d_dir);
124 set %IF &l_autonr>0 %THEN &d_examinee; &d_dir(in=indir);
127 source=symgetc (
"l_auto");
130 %LET l_autonr = %eval(&l_autonr+1);
132 %IF %symexist(g_sasautos&l_autonr) %THEN %LET l_auto=&&g_sasautos&l_autonr;
134 %IF (&g_crossrefsasunit.) %THEN %DO;
135 %LET l_auto=&g_sasunit;
136 %LET l_auto=%quote(&l_auto/);
137 %_dir(i_path=&l_auto.*.sas, o_out=&d_dir);
139 set &d_examinee &d_dir(in=indir);
142 source=symgetc (
"l_auto");
145 %LET l_auto=&g_sasunit_os;
146 %LET l_auto=%quote(&l_auto/);
147 %_dir(i_path=&l_auto.*.sas, o_out=&d_dir);
149 set &d_examinee &d_dir(in=indir);
152 source=symgetc (
"l_auto");
158 %_crossreference(i_includeSASUnit = &g_crossrefsasunit.
159 ,i_examinee = &d_examinee.
160 ,o_listcalling = &d_listcalling.
161 ,o_dependency = &d_dependency.
162 ,o_macroList = &d_macroList.
166 %_checkScenario(i_examinee = &d_examinee.
167 ,i_scn_pre = &D_SCN_PRE.
168 ,i_dependency = &d_dependency.
169 ,i_scenariosToRun = &d_scenariosToRun.
173 %_deletescenariofiles(i_scenariosToRun=&d_scenariosToRun.
177 DELETE * FROM target.cas WHERE cas_scnid in (select scn_id from &d_scenariosToRun where dorun=1);
178 DELETE * FROM target.tst WHERE tst_scnid in (select scn_id from &d_scenariosToRun where dorun=1);
183 SET target.scn &d_scenariosToRun(where=(insertIntoDB=1) in=add);
185 scn_path = resolve(
'%_stdPath(&g_root,' || filename ||
')');
186 drop filename dorun insertIntoDB name;
192 select count(scn_id) into :l_nscn
193 from &d_scenariosToRun
202 set &d_scenariosToRun point=in;
203 Call Symputx('l_scnid',scn_id, 'L');
204 Call Symputx('l_dorun',dorun, 'L');
205 Call Symputx('l_filename',filename, 'L');
209 %LET l_scn = %_stdPath(&g_root,&l_filename);
211 %IF &l_dorun %THEN %DO;
212 %PUT ======== test scenario &l_scnid (&l_scn) will be run ========;
217 %PUT ======== test scenario &l_scnid (&l_scn) will not be run ==;
223 %IF &l_dorun %THEN %DO;
226 %_getPgmDesc (i_pgmfile=&l_filename, r_desc=l_scndesc)
228 UPDATE target.scn SET
229 scn_desc = "&l_scndesc"
230 ,scn_start = %sysfunc(datetime())
231 WHERE scn_id = &l_scnid
235 %LET l_c_scnid = %substr(00&l_scnid.,%length(&l_scnid));
236 %LET l_scnlogfullpath = &g_log/&l_c_scnid..log;
237 %_runProgramSpawned(i_program =&l_filename
238 ,i_scnid =&l_c_scnid.
239 ,i_generateMcoverage=&g_testcoverage.
245 %LET l_lstfile=&g_testout/%substr(00&l_scnid,%length(&l_scnid)).lst;
246 %IF %SYSFUNC(FILEEXIST("&l_lstfile")) %THEN %DO;
250 CALL symput ('l_filled','1');
254 %IF NOT &l_filled %THEN %DO;
255 %LET l_filled=%_delfile(&l_lstfile);
261 i_logfile = &l_scnlogfullpath.
263 ,i_warning = &g_warning.
264 ,r_errors = l_error_count
265 ,r_warnings= l_warning_count
270 %*** Treat missing scenario as error ***;
273 SELECT max (cas_res) INTO :l_result FROM target.cas WHERE cas_scnid=&l_scnid;
275 %*** Treat missing scenario as failed and treat scenario with errors in scenario log as failed ***;
276 %if (&l_result. = . or &l_error_count. > 0) %then %let l_result=2;
280 scn_end = %sysfunc(datetime())
282 ,scn_errorcount = &l_error_count.
283 ,scn_warningcount = &l_warning_count.
284 ,scn_res = &l_result.
289 UPDATE &d_scenariosToRun
302 %PUT =========================== Error! runSASUnit aborted! ==========================================;
306 %IF %EVAL("%UPCASE(&g_error_code.)" EQ "%UPCASE(NoSourceFiles)") %THEN %DO;
310 %LET l_scn = %_stdPath(&g_root., &l_source.);
312 %LET l_nscncount = 0;
315 INTO :l_nscncount SEPARATED BY ''
317 WHERE Upcase(scn_path) = "%UPCASE(&l_scn.)";
320 %IF %EVAL(&l_nscncount. EQ 0) %THEN %DO;
322 %LET l_scndesc = %STR(Scenario not found - has to fail!);
325 SELECT max(scn_id) INTO :l_scnid FROM target.scn;
326 %IF &l_scnid=. %THEN %LET l_scnid=0;
327 %LET l_scnid = %eval(&l_scnid+1);
328 INSERT INTO target.scn
358 PROC DATASETS NOLIST NOWARN LIB=%scan(&d_dependency,1,.);
359 DELETE %scan(&d_dependency,2,.);
360 DELETE %scan(&d_dir,2,.);
361 DELETE %scan(&d_examinee,2,.);
362 DELETE %scan(&d_scenariosToRun,2,.);
363 DELETE %scan(&d_scn_pre,2,.);