SASUnit Examples  Version 1.5.0
windows/_runprogramspawned.sas
Go to the documentation of this file.
1 
25 %macro _runProgramSpawned(i_program =
26  ,i_scnid =
27  ,i_generateMcoverage = 0
28  ,r_sysrc =
29  );
30 
31  %local l_cmdFile l_parms l_parenthesis l_tcgFilePath l_tcgOptionsString l_tcgOptionsStringLINUX l_rc l_macname;
32  %let l_macname=&sysmacroname.;
33 
34  /*-- prepare sasuser ---------------------------------------------------*/
35  %let l_cmdFile=%sysfunc(pathname(work))/prep_sasuser.cmd;
36  DATA _null_;
37  FILE "&l_cmdFile.";
38  PUT "&g_removedir ""%sysfunc(pathname(work))/sasuser""&g_endcommand";
39  PUT "&g_makedir ""%sysfunc(pathname(work))/sasuser""&g_endcommand";
40  %IF %length(&g_sasuser) %THEN %DO;
41  PUT "&g_copydir ""&g_sasuser"" ""%sysfunc(pathname(work))/sasuser""&g_endcommand";
42  %END;
43  RUN;
44  %_executeCMDFile(&l_cmdFile.);
45  %LET l_rc=%_delfile(&l_cmdFile.);
46 
47  /*-- set config and autoexec -------------------------------------------*/
48  %let l_cmdFile=%sysfunc(pathname(work))/_runprogramspawned.cmd;
49  %LET l_parms=;
50  %LET l_parenthesis=(;
51  %IF "&g_autoexec" NE "" %THEN %DO;
52  %LET l_parms=&l_parms -autoexec ""&g_autoexec"";
53  %END;
54  %IF "&g_sascfg" NE "" %THEN %DO;
55  %LET l_parms=&l_parms -config ""&g_sascfg"";
56  %END;
57  %ELSE %IF %length(%sysfunc(getoption(config))) NE 0 AND %index(%quote(%sysfunc(getoption(config))),%bquote(&l_parenthesis)) NE 1 %THEN %DO;
58  %LET l_parms=&l_parms -config ""%sysfunc(getoption(config))"";
59  %END;
60 
61  %IF &i_generateMcoverage. EQ 1 %THEN %DO;
62  /*-- generate a local macro variable containing the
63  path to the generated coverage file if necessary ---------------*/
64  %LET l_tcgFilePath = &g_log./&i_scnid..tcg;
65  %LET l_tcgOptionsString = -mcoverage -mcoverageloc = ""&l_tcgFilePath."";
66  %END;
67 
68  DATA _null_;
69  ATTRIB
70  _sCmdString LENGTH = $32000
71  ;
72  FILE
73  "&l_cmdFile."
74  LRECL=32000
75  ;
76  _sCmdString =
77  """" !! &g_sasstart !! """"
78  !! " "
79  !! "&l_parms. "
80  !! "-sysin ""&i_program."" "
81  !! "-initstmt ""%nrstr(%%%_scenario%(io_target=)&g_target%nrstr(%);%%%let g_scnid=)&i_scnid.;"" "
82  !! "-log ""&g_log/&i_scnid..log"" "
83  !! "-print ""&g_testout/&i_scnid..lst"" "
84  !! "&g_splash "
85  !! "-noovp "
86  !! "-icon "
87  !! "-nosyntaxcheck "
88  !! "-mautosource "
89  !! "-mcompilenote all "
90  !! "-sasautos ""&g_sasunit"" "
91  !! "-sasuser ""%sysfunc(pathname(work))/sasuser"" "
92  !! "-termstmt ""%nrstr(%%%_termScenario())"" "
93  !! "&l_tcgOptionsString. "
94  !! "";
95  PUT _sCmdString;
96  RUN;
97 
98  %_executeCMDFile(&l_cmdFile.);
99  %LET &r_sysrc. = &sysrc.;
100  %LET l_rc=%_delfile(&l_cmdFile.);
101 
102  /*-- delete sasuser ----------------------------------------------------*/
103  %let l_cmdFile=%sysfunc(pathname(work))/del_sasuser.cmd;
104  DATA _null_;
105  FILE "&l_cmdFile.";
106  PUT "&g_removedir ""%sysfunc(pathname(work))/sasuser""&g_endcommand";
107  RUN;
108  %_executeCMDFile(&l_cmdFile.);
109  %LET l_rc=%_delfile(&l_cmdFile.);
110 
111 %mend _runprogramspawned;
112