SASUnit Examples  Version 1.2.1
initsasunit.sas
Go to the documentation of this file.
1 
47 /* change log
48  08.02.2013 PW new parameter i_testcoverage
49  29.01.2013 KL changed link from _sasunit_doc.sas to Sourceforge SASUnit User's Guide
50  08.01.2013 KL Fixed warning concerning %substr arguments. This was caused by the last call in run_all.sas.
51  To remove the entry for i_autoexec, a real blank must be passed. So there is now a different
52  method used for check on empty parameter which now must include a real blank as empty.
53 */
54 
55 
56 %MACRO initSASUnit(
57  i_root =
58  ,io_target =
59  ,i_overwrite = 0
60  ,i_project =
61  ,i_sasunit =
62  ,i_sasautos =
63  ,i_sasautos1 =
64  ,i_sasautos2 =
65  ,i_sasautos3 =
66  ,i_sasautos4 =
67  ,i_sasautos5 =
68  ,i_sasautos6 =
69  ,i_sasautos7 =
70  ,i_sasautos8 =
71  ,i_sasautos9 =
72  ,i_autoexec =
73  ,i_sascfg =
74  ,i_sasuser =
75  ,i_testdata =
76  ,i_refdata =
77  ,i_doc =
78  ,i_testcoverage = 0
79 );
80 %LOCAL l_macname; %LET l_macname=&sysmacroname;
81 %LOCAL l_first_temp;
82 
83 /*-- Resolve relative root path like .../. to an absolute root path ----------*/
84 libname _tmp "&i_root.";
85 %let i_root=%sysfunc (pathname(_tmp));
86 libname _tmp clear;
87 
88 /*-- initialize error --------------------------------------------------------*/
89 %_sasunit_initErrorHandler;
90 
91 /*-- check for operation system ----------------------------------------------*/
92 %IF %_sasunit_handleError( &l_macname
93  , WrongOS
94  , (&sysscp. NE WIN) AND (&sysscp. NE LINUX)
95  , Invalid operating system - only WIN and LINUX)
96 %THEN %GOTO errexit;
97 
98 /*-- set macro symbols for os commands ---------------------------------------*/
99 %_sasunit_oscmds;
100 
101 /*-- check SAS version -------------------------------------------------------*/
102 %IF %_sasunit_handleError( &l_macname
103  , WrongVer
104  , (&sysver. NE 9.1) AND (&sysver. NE 9.2) AND (&sysver. NE 9.3)
105  , Invalid SAS version - only SAS 9.1 to 9.3)
106 %THEN %GOTO errexit;
107 
108 /*-- check value of parameter i_testcoverage, if it has an other value than 1,
109  set it to 0 in order to assure that it will have only value 0 or 1 ------*/
110 %IF &i_testcoverage. NE 1 %THEN %DO;
111  %LET i_testcoverage = 0;
112 %END;
113 %ELSE %DO;
114  /*-- if test coverage should be assessed: check SAS version --------------*/
115  %IF %_sasunit_handleError( &l_macname
116  , WrongTcVer
117  , &sysver. NE 9.3
118  , Invalid SAS version for test coverage assessment - only 9.3 supported)
119  %THEN %GOTO errexit;
120 %END;
121 
122 /*-- check for target directory ----------------------------------------------*/
123 %LOCAL l_target_abs;
124 %LET l_target_abs=%_sasunit_abspath(&i_root,&io_target);
125 %IF %_sasunit_handleError(&l_macname, InvalidTargetDir,
126  "&l_target_abs" EQ "" OR NOT %_sasunit_existDir(&l_target_abs),
127  Error in parameter io_target: target directory does not exist)
128  %THEN %GOTO errexit;
129 
130 LIBNAME target "&l_target_abs";
131 %IF %_sasunit_handleError(&l_macname, ErrorTargetLib,
132  %quote(&syslibrc) NE 0,
133  Error in parameter io_target: target directory &l_target_abs. cannot be assigned as a SAS library)
134  %THEN %GOTO errexit;
135 data target._test;
136 run;
137 %IF %_sasunit_handleError(&l_macname, ErrorTargetLibNotWritable,
138  %quote(&syserr) NE 0,
139  Error in parameter io_target: target directory not writeable)
140  %THEN %GOTO errexit;
141 PROC SQL;
142  DROP TABLE target._test;
143 QUIT;
144 
145 /*-- does the test database exist already? -----------------------------------*/
146 %LOCAL l_newdb;
147 %IF "&i_overwrite" NE "1" %then %LET i_overwrite=0;
148 %IF &i_overwrite %THEN %LET l_newdb=1;
149 %ELSE %LET l_newdb=%eval(NOT %sysfunc(exist(target.tsu)));
150 
151 /*-- create test database if necessary ---------------------------------------*/
152 %IF &l_newdb %THEN %DO;
153 PROC SQL NOPRINT;
154  CREATE TABLE target.tsu ( /* test suite */
155  tsu_project CHAR(255) /* see i_project */
156  ,tsu_root CHAR(255) /* see i_root */
157  ,tsu_target CHAR(255) /* see io_target */
158  ,tsu_sasunit CHAR(255) /* see i_sasunit */
159  ,tsu_sasautos CHAR(255) /* see i_sasautos */
160 %DO i=1 %TO 9;
161  ,tsu_sasautos&i CHAR(255) /* see i_sasautos<n> */
162 %END;
163  ,tsu_autoexec CHAR(255) /* see i_autoexec */
164  ,tsu_sascfg CHAR(255) /* see i_sascfg */
165  ,tsu_sasuser CHAR(255) /* see i_sasuser */
166  ,tsu_testdata CHAR(255) /* see i_testdata */
167  ,tsu_refdata CHAR(255) /* see i_refdata */
168  ,tsu_doc CHAR(255) /* see i_doc */
169  ,tsu_lastinit INT FORMAT=datetime21.2 /* date and time of last initialization */
170  ,tsu_lastrep INT FORMAT=datetime21.2 /* date and time of last report generation*/
171  );
172  INSERT INTO target.tsu VALUES (
173  "","","","","","","","","","","","","","","","","","","","",0,0
174  );
175 
176  CREATE TABLE target.scn ( /* test scenario */
177  scn_id INT FORMAT=z3. /* number of scenario */
178  ,scn_path CHAR(255) /* path to program file */
179  ,scn_desc CHAR(255) /* description of program (brief tag in comment header) */
180  ,scn_start INT FORMAT=datetime21.2 /* starting date and time of the last run */
181  ,scn_end INT FORMAT=datetime21.2 /* ending date and time of the last run */
182  ,scn_rc INT /* return code of SAS session of last run */
183  ,scn_errorcount INT /* number of detected errors in the scenario log */
184  ,scn_warningcount INT /* number of detected warnings in the scenario log */
185  ,scn_res INT /* overall test result of last run: 0 .. OK, 1 .. not OK, 2 .. manual */
186  );
187  CREATE TABLE target.cas ( /* test case */
188  cas_scnid INT FORMAT=z3. /* reference to test scenario */
189  ,cas_id INT FORMAT=z3. /* sequential number of test case within test scenario */
190  ,cas_auton INT /* number of autocall path where program under test has been found or ., if not found */
191  ,cas_pgm CHAR(255) /* file name of program under test: only name if found in autocall paths, or fully qualified path otherwise */
192  ,cas_desc CHAR(255) /* description of test case */
193  ,cas_spec CHAR(255) /* optional: specification document, fully qualified path or only filename to be found in folder &g_doc */
194  ,cas_start INT FORMAT=datetime21.2 /* starting date and time of the last run */
195  ,cas_end INT FORMAT=datetime21.2 /* ending date and time of the last run */
196  ,cas_res INT /* overall test result of last run: 0 .. OK, 1 .. not OK, 2 .. manual */
197  );
198  CREATE TABLE target.tst ( /* Test */
199  tst_scnid INT FORMAT=z3. /* reference to test scenario */
200  ,tst_casid INT FORMAT=z3. /* reference to test case */
201  ,tst_id INT FORMAT=z3. /* sequential number of test within test case */
202  ,tst_type CHAR(32) /* type of test (name of assert macro) */
203  ,tst_desc CHAR(255) /* description of test */
204  ,tst_exp CHAR(255) /* expected result */
205  ,tst_act CHAR(255) /* actual result */
206  ,tst_res INT /* test result of the last run: 0 .. OK, 1 .. not OK, 2 .. manual */
207  );
208 QUIT;
209 %IF %_sasunit_handleError(&l_macname, ErrorCreateDB,
210  &syserr NE 0,
211  Error on creation of test database)
212  %THEN %GOTO errexit;
213 
214 
215 /*-- regenerate empty folders ------------------------------------------------*/
216 DATA _null_;
217  FILE "%sysfunc(pathname(work))/x.cmd" encoding=pcoem850;/* wg. Umlauten in Pfaden */
218  PUT "&g_removedir ""&l_target_abs/log""&g_endcommand";
219  PUT "&g_removedir ""&l_target_abs/tst""&g_endcommand";
220  PUT "&g_removedir ""&l_target_abs/rep""&g_endcommand";
221  PUT "&g_makedir ""&l_target_abs/log""&g_endcommand";
222  PUT "&g_makedir ""&l_target_abs/tst""&g_endcommand";
223  PUT "&g_makedir ""&l_target_abs/rep""&g_endcommand";
224 RUN;
225 %if &sysscp. = LINUX %then %do;
226  %_sasunit_xcmd(chmod u+x "%sysfunc(pathname(work))/x.cmd")
227 %end;
228 %_sasunit_xcmd("%sysfunc(pathname(work))/x.cmd")
229 %LOCAL l_rc;
230 %LET l_rc=_sasunit_delfile(%sysfunc(pathname(work))/x.cmd);
231 
232 %END; /* %if &l_newdb */
233 
234 /*-- add and fill column tsu_testcoverage------------------------------------------*/
235 %LOCAL l_col_testcoverage_exists;
236 DATA _null_;
237  dsid=open('target.tsu');
238  varcheck=varnum(dsid,'tsu_testcoverage');
239  CALL SYMPUTX('l_col_testcoverage_exists',varcheck);
240 RUN;
241 PROC SQL NOPRINT;
242  %IF (NOT &l_col_testcoverage_exists.) %THEN %DO;
243  ALTER TABLE target.tsu
244  ADD tsu_testcoverage INT;
245  %END;
246 
247  UPDATE target.tsu SET tsu_testcoverage = &i_testcoverage.;
248 QUIT;
249 
250 /*-- check folders -----------------------------------------------------------*/
251 %IF %_sasunit_handleError(&l_macname, NoLogDir,
252  NOT %_sasunit_existdir(&l_target_abs/log),
253  folder &l_target_abs/log does not exist)
254  %THEN %GOTO errexit;
255 %IF %_sasunit_handleError(&l_macname, NoTstDir,
256  NOT %_sasunit_existdir(&l_target_abs/tst),
257  folder &l_target_abs/tst does not exist)
258  %THEN %GOTO errexit;
259 %IF %_sasunit_handleError(&l_macname, NoRepDir,
260  NOT %_sasunit_existdir(&l_target_abs/rep),
261  folder &l_target_abs/rep does not exist)
262  %THEN %GOTO errexit;
263 PROC SQL NOPRINT;
264  UPDATE target.tsu SET tsu_target = "&io_target";
265 QUIT;
266 
267 /*-- project name ------------------------------------------------------------*/
268 %LOCAL l_project;
269 PROC SQL NOPRINT;
270  SELECT tsu_project INTO :l_project FROM target.tsu;
271 QUIT;
272 %LET l_project=&l_project;
273 %IF "&i_project" NE "" %THEN %LET l_project=&i_project;
274 %IF %_sasunit_handleError(&l_macname, MissingProjectName,
275  "&l_project" EQ "",
276  Parameter i_project must be specified)
277  %THEN %GOTO errexit;
278 PROC SQL NOPRINT;
279  UPDATE target.tsu SET tsu_project = "&l_project";
280 QUIT;
281 
282 /*-- root folder -------------------------------------------------------------*/
283 %LOCAL l_root;
284 PROC SQL NOPRINT;
285  SELECT tsu_root INTO :l_root FROM target.tsu;
286 QUIT;
287 %LET l_root=&l_root;
288 %IF "&i_root" NE "" %THEN %LET l_root=&i_root;
289 %IF %_sasunit_handleError(&l_macname, InvalidRoot,
290  "&l_root" NE "" AND NOT %_sasunit_existdir(&l_root),
291  %str(Error in parameter i_root: folder must exist when specified))
292  %THEN %GOTO errexit;
293 PROC SQL NOPRINT;
294  UPDATE target.tsu SET tsu_root = "&l_root";
295 QUIT;
296 
297 /*-- sasunit folder ----------------------------------------------------------*/
298 %LOCAL l_sasunit l_sasunit_abs;
299 PROC SQL NOPRINT;
300  SELECT tsu_sasunit INTO :l_sasunit FROM target.tsu;
301 QUIT;
302 %LET l_sasunit=&l_sasunit;
303 %IF "&i_sasunit" NE "" %THEN %LET l_sasunit=&i_sasunit;
304 %LET l_sasunit_abs=%_sasunit_abspath(&l_root,&l_sasunit);
305 %IF %_sasunit_handleError(&l_macname, InvalidSASUnitDir,
306  "&l_sasunit_abs" EQ "" OR NOT %sysfunc(fileexist(&l_sasunit_abs/_sasunit_scenario.sas)),
307  Error in parameter i_sasunit: SASUnit macro programs not found)
308  %THEN %GOTO errexit;
309 PROC SQL NOPRINT;
310  UPDATE target.tsu SET tsu_sasunit = "&l_sasunit";
311 QUIT;
312 
313 /*-- check if autoexec exists where specified --------------------------------*/
314 %LOCAL l_autoexec l_autoexec_abs;
315 PROC SQL NOPRINT;
316  SELECT tsu_autoexec INTO :l_autoexec FROM target.tsu;
317 QUIT;
318 %LET l_autoexec=&l_autoexec;
319 %*** because we need to specify a real blank (%str( )) as parameter, ***;
320 %*** we need to use a different method of assignment. ***;
321 %IF "&i_autoexec" NE "" %THEN %LET l_autoexec=%trim(&i_autoexec);
322 %LET l_autoexec_abs=%_sasunit_abspath(&l_root,&l_autoexec);
323 %IF %_sasunit_handleError(&l_macname, AutoexecNotFound,
324  "&l_autoexec" NE "" AND NOT %sysfunc(fileexist(&l_autoexec_abs%str( ))),
325  Error in parameter i_autoexec: file not found)
326  %THEN %GOTO errexit;
327 PROC SQL NOPRINT;
328  UPDATE target.tsu SET tsu_autoexec = "&l_autoexec";
329 QUIT;
330 
331 /*-- check if sascfg exists where specified ----------------------------------*/
332 %LOCAL l_sascfg l_sascfg_abs;
333 PROC SQL NOPRINT;
334  SELECT tsu_sascfg INTO :l_sascfg FROM target.tsu;
335 QUIT;
336 %LET l_sascfg=&l_sascfg;
337 %IF "&i_sascfg" NE "" %THEN %LET l_sascfg=&i_sascfg;
338 %LET l_sascfg_abs=%_sasunit_abspath(&l_root,&l_sascfg);
339 %IF %_sasunit_handleError(&l_macname, SASCfgNotFound,
340  "&l_sascfg" NE "" AND NOT %sysfunc(fileexist(&l_sascfg_abs%str( ))),
341  Error in parameter i_sascfg: file not found)
342  %THEN %GOTO errexit;
343 PROC SQL NOPRINT;
344  UPDATE target.tsu SET tsu_sascfg = "&l_sascfg";
345 QUIT;
346 
347 /*-- check sasuser folder ----------------------------------------------------*/
348 %LOCAL l_sasuser l_sasuser_abs;
349 PROC SQL NOPRINT;
350  SELECT tsu_sasuser INTO :l_sasuser FROM target.tsu;
351 QUIT;
352 %LET l_sasuser=&l_sasuser;
353 %IF "&i_sasuser" NE "" %THEN %LET l_sasuser=&i_sasuser;
354 %LET l_sasuser_abs=%_sasunit_abspath(&l_root,&l_sasuser);
355 %IF %_sasunit_handleError(&l_macname, InvalidSasuser,
356  "&l_sasuser_abs" NE "" AND NOT %_sasunit_existdir(&l_sasuser_abs),
357  Error in parameter i_sasuser: folder not found)
358  %THEN %GOTO errexit;
359 PROC SQL NOPRINT;
360  UPDATE target.tsu SET tsu_sasuser = "&l_sasuser";
361 QUIT;
362 
363 /*-- check test data folder --------------------------------------------------*/
364 %LOCAL l_testdata l_testdata_abs;
365 PROC SQL NOPRINT;
366  SELECT tsu_testdata INTO :l_testdata FROM target.tsu;
367 QUIT;
368 %LET l_testdata=&l_testdata;
369 %IF "&i_testdata" NE "" %THEN %LET l_testdata=&i_testdata;
370 %LET l_testdata_abs=%_sasunit_abspath(&l_root,&l_testdata);
371 %IF %_sasunit_handleError(&l_macname, InvalidTestdata,
372  "&l_testdata_abs" NE "" AND NOT %_sasunit_existdir(&l_testdata_abs),
373  Error in parameter i_testdata: folder not found)
374  %THEN %GOTO errexit;
375 PROC SQL NOPRINT;
376  UPDATE target.tsu SET tsu_testdata = "&l_testdata";
377 QUIT;
378 
379 /*-- check reference data folder ---------------------------------------------*/
380 %LOCAL l_refdata l_refdata_abs;
381 PROC SQL NOPRINT;
382  SELECT tsu_refdata INTO :l_refdata FROM target.tsu;
383 QUIT;
384 %LET l_refdata=&l_refdata;
385 %IF "&i_refdata" NE "" %THEN %LET l_refdata=&i_refdata;
386 %LET l_refdata_abs=%_sasunit_abspath(&l_root,&l_refdata);
387 %IF %_sasunit_handleError(&l_macname, InvalidRefdata,
388  "&l_refdata_abs" NE "" AND NOT %_sasunit_existdir(&l_refdata_abs),
389  Error in parameter i_refdata: folder not found)
390  %THEN %GOTO errexit;
391 PROC SQL NOPRINT;
392  UPDATE target.tsu SET tsu_refdata = "&l_refdata";
393 QUIT;
394 
395 /*-- check folder for specification documents --------------------------------*/
396 %LOCAL l_doc l_doc_abs;
397 PROC SQL NOPRINT;
398  SELECT tsu_doc INTO :l_doc FROM target.tsu;
399 QUIT;
400 %LET l_doc=&l_doc;
401 %IF "&i_doc" NE "" %THEN %LET l_doc=&i_doc;
402 %LET l_doc_abs=%_sasunit_abspath(&l_root,&l_doc);
403 %IF %_sasunit_handleError(&l_macname, InvalidDoc,
404  "&l_doc_abs" NE "" AND NOT %_sasunit_existdir(&l_doc_abs),
405  Error in parameter i_doc: folder not found)
406  %THEN %GOTO errexit;
407 PROC SQL NOPRINT;
408  UPDATE target.tsu SET tsu_doc = "&l_doc";
409 QUIT;
410 
411 /*-- check autocall paths ----------------------------------------------------*/
412 %LOCAL restore_sasautos l_sasautos l_sasautos_abs i;
413 %LET restore_sasautos=%sysfunc(getoption(sasautos));
414 
415 PROC SQL NOPRINT;
416  SELECT tsu_sasautos INTO :l_sasautos FROM target.tsu;
417 QUIT;
418 %LET l_sasautos=&l_sasautos;
419 %IF "&i_sasautos" NE "" %THEN %LET l_sasautos=&i_sasautos;
420 %LET l_sasautos_abs=%_sasunit_abspath(&l_root,&l_sasautos);
421 %IF %_sasunit_handleError(&l_macname, InvalidSASAutos,
422  "&l_sasautos_abs" NE "" AND NOT %_sasunit_existdir(&l_sasautos_abs),
423  Error in parameter i_sasautos: folder not found)
424  %THEN %GOTO errexit;
425 PROC SQL NOPRINT;
426  UPDATE target.tsu SET tsu_sasautos = "&l_sasautos";
427 QUIT;
428 
429 %DO i=1 %TO 9;
430 PROC SQL NOPRINT;
431  SELECT tsu_sasautos&i INTO :l_sasautos FROM target.tsu;
432 QUIT;
433 %LET l_sasautos=&l_sasautos;
434 %IF "&&i_sasautos&i" NE "" %THEN %LET l_sasautos=&&i_sasautos&i;
435 %LET l_sasautos_abs=%_sasunit_abspath(&l_root,&l_sasautos);
436 %IF %_sasunit_handleError(&l_macname, InvalidSASAutosN,
437  "&l_sasautos_abs" NE "" AND NOT %_sasunit_existdir(&l_sasautos_abs),
438  Error in parameter i_sasautos&i: folder not found)
439  %THEN %GOTO errexit;
440 PROC SQL NOPRINT;
441  UPDATE target.tsu SET tsu_sasautos&i = "&l_sasautos";
442 QUIT;
443 %END; /* i=1 %TO 9 */
444 
445 /*-- load relevant information from test database to global macro symbols ----*/
446 %_sasunit_loadEnvironment (
447  i_withLibrefs = 0
448 )
449 %IF "&g_error_code" NE "" %THEN %GOTO errexit;
450 
451 %if &sysscp. = WIN %then %do;
452  /*-- options for OS commands ----------------------------------------------*/
453  options noxwait xsync xmin;
454 %end;
455 
456 /*-- check spawning of a SAS process -----------------------------------------*/
457 /* a file will be created in the work library of the parent (this) process
458  to check whether spawning works */
459 %LOCAL l_work;
460 %LET l_work = %sysfunc(pathname(work));
461 PROC DATASETS NOLIST NOWARN LIB=work;
462  DELETE check;
463 QUIT;
464 
465 DATA _null_;
466  FILE "%sysfunc(pathname(work))/x.cmd";
467  PUT "&g_removedir ""%sysfunc(pathname(work))/sasuser""&g_endcommand";
468  PUT "&g_makedir ""%sysfunc(pathname(work))/sasuser""&g_endcommand";
469 %IF %length(&g_sasuser) %THEN %DO;
470  PUT "&g_copydir ""&g_sasuser"" ""%sysfunc(pathname(work))/sasuser""&g_endcommand";
471 %END;
472 RUN;
473 %if &sysscp. = LINUX %then %do;
474  %_sasunit_xcmd(chmod u+x "%sysfunc(pathname(work))/x.cmd")
475 %end;
476 %_sasunit_xcmd("%sysfunc(pathname(work))/x.cmd")
477 %LOCAL l_rc;
478 %LET l_rc=_sasunit_delfile(%sysfunc(pathname(work))/x.cmd);
479 
480 DATA _null_;
481  FILE "&l_work/run.sas";
482  PUT "LIBNAME awork ""&l_work"";";
483  PUT "DATA awork.check; RUN;";
484 RUN;
485 %LOCAL l_parms;
486 %IF "&g_autoexec" NE "" %THEN %DO;
487  %LET l_parms=&l_parms -autoexec ""&g_autoexec"";
488 %END;
489 %IF "&g_sascfg" NE "" %THEN %DO;
490  %IF &sysscp. = LINUX %THEN %DO;
491  %IF "&g_sascfg" NE "" %THEN %DO;
492  options SET=SASCFGPATH "&g_sascfg.";
493  %END;
494  %END;
495  %ELSE %DO;
496  %LET l_parms=&l_parms -config ""&g_sascfg"";
497  %END;
498 %END;
499 
500 
501 DATA _null_;
502  ATTRIB
503  _sCmdString LENGTH = $32000
504  ;
505  FILE
506  "%sysfunc(pathname(work))/xxx.cmd"
507  LRECL=32000
508  ;
509 %IF &sysscp. = LINUX %THEN %DO;
510  _sCmdString =
511  "" !! &g_sasstart.
512  !! " "
513  !! "&l_parms. "
514  !! "-sysin &l_work./run.sas "
515  !! "-initstmt ""%nrstr(%%_sasunit_scenario%(io_target=)&g_target%nrstr(%);)"" "
516  !! "-log &g_log./000.log "
517  !! "-print &g_log./000.lst "
518  !! "-noovp "
519  !! "-nosyntaxcheck "
520  !! "-mautosource "
521  !! "-mcompilenote all "
522  !! "-sasautos &g_sasunit "
523  !! "-sasuser %sysfunc(pathname(work))/sasuser "
524  !! "";
525 %END;
526 %ELSE %DO;
527  _sCmdString =
528  """" !! &g_sasstart !! """"
529  !! " "
530  !! "&l_parms. "
531  !! "-sysin ""&l_work./run.sas"" "
532  !! "-initstmt ""%nrstr(%%%_sasunit_scenario%(io_target=)&g_target%nrstr(%);)"" "
533  !! "-log ""&g_log./000.log"" "
534  !! "-print ""&g_log./000.lst"" "
535  !! "&g_splash "
536  !! "-noovp "
537  !! "-nosyntaxcheck "
538  !! "-mautosource "
539  !! "-mcompilenote all "
540  !! "-sasautos ""&g_sasunit"" "
541  !! "-sasuser ""%sysfunc(pathname(work))/sasuser"" "
542  !! "";
543 %END;
544  PUT _sCmdString
545  ;
546 RUN;
547 
548 %IF &sysscp. = LINUX %THEN %DO;
549  %_sasunit_xcmd(chmod u+x "%sysfunc(pathname(work))/xxx.cmd");
550  %_sasunit_xcmd(sed -i -e 's/\r//g' %sysfunc(pathname(work))/xxx.cmd);
551 %END;
552 
553 %_sasunit_xcmd("%sysfunc(pathname(work))/xxx.cmd")
554 %LET l_rc=_sasunit_delfile(%sysfunc(pathname(work))/xxx.cmd);
555 %LET l_sysrc = &sysrc;
556 
557 %IF %_sasunit_handleError(&l_macname, ErrorSASCall2,
558  NOT %sysfunc(exist(work.check)),
559  Error spawning SAS process in initialization)
560  %THEN %GOTO errexit;
561 
562 PROC DATASETS NOLIST NOWARN LIB=work;
563  DELETE check;
564 QUIT;
565 
566 %LET l_rc=%_sasunit_delFile(&l_work/run.sas);
567 
568 /*-- save time of initialization ---------------------------------------------*/
569 PROC SQL NOPRINT;
570  UPDATE target.tsu
571  SET tsu_lastinit = %sysfunc(datetime())
572  ;
573 QUIT;
574 
575 %PUT;
576 %PUT ============================ SASUnit has been initialized successfully ==========================;
577 %PUT;
578 
579 %GOTO exit;
580 %errexit:
581  %PUT;
582  %PUT &g_error: ===================== Error! Testsuite aborted! ===========================================;
583  %PUT;
584  LIBNAME target;
585 %exit:
586 %MEND initSASUnit;