SASUnit Examples  Version 1.5.0
linux/_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  options SET=SASCFGPATH "&g_sascfg.";
56  %END;
57 
58  %IF &i_generateMcoverage. EQ 1 %THEN %DO;
59  /*-- generate a local macro variable containing the
60  path to the generated coverage file if necessary ---------------*/
61  %LET l_tcgFilePath = &g_log./&i_scnid..tcg;
62  %LET l_tcgOptionsString = options mcoverage mcoverageloc='%sysfunc(tranwrd(&l_tcgFilePath.,%str( ), %str(\ )))';
63  %END;
64 
65  DATA _null_;
66  ATTRIB
67  _sCmdString LENGTH = $32000
68  ;
69  FILE
70  "&l_cmdFile."
71  LRECL=32000
72  ;
73  _sCmdString =
74  "" !! &g_sasstart.
75  !! " "
76  !! "&l_parms. "
77  !! "-sysin %sysfunc(tranwrd(&i_program., %str( ), %str(\ ))) "
78  !! "-initstmt "" &l_tcgOptionsString.; %nrstr(%%_scenario%(io_target=)&g_target%nrstr(%);%%let g_scnid=)&i_scnid.;"" "
79  !! "-log %sysfunc(tranwrd(&g_log/&i_scnid..log, %str( ), %str(\ ))) "
80  !! "-print %sysfunc(tranwrd(&g_testout/&i_scnid..lst, %str( ), %str(\ ))) "
81  !! "-noovp "
82  !! "-nosyntaxcheck "
83  !! "-mautosource "
84  !! "-mcompilenote all "
85  !! "-sasautos %sysfunc(tranwrd(&g_sasunit, %str( ), %str(\ ))) "
86  !! "-sasuser %sysfunc(pathname(work))/sasuser "
87  !! "-termstmt ""%nrstr(%%_termScenario())"" "
88  !! "";
89  PUT _sCmdString;
90  RUN;
91 
92  %_executeCMDFile(&l_cmdFile.);
93  %LET &r_sysrc. = &sysrc.;
94  %LET l_rc=%_delfile(&l_cmdFile.);
95 
96  /*-- delete sasuser ----------------------------------------------------*/
97  %let l_cmdFile=%sysfunc(pathname(work))/del_sasuser.cmd;
98  DATA _null_;
99  FILE "&l_cmdFile.";
100  PUT "&g_removedir ""%sysfunc(pathname(work))/sasuser""&g_endcommand";
101  RUN;
102  %_executeCMDFile(&l_cmdFile.);
103  %LET l_rc=%_delfile(&l_cmdFile.);
104 
105  %mend _runprogramspawned;
106