SASUnit Examples  Version 1.5.0
_loadenvironment.sas
Go to the documentation of this file.
1 
21 %MACRO _loadEnvironment(i_withlibrefs = 1
22  );
23 
24  %LOCAL l_macname; %LET l_macname=&sysmacroname;
25 
26  %GLOBAL g_sasunitroot g_target g_project g_root g_sasunit g_sasunit_os g_autoexec g_sascfg g_sasuser
27  g_sasautos g_sasautos0 g_sasautos1 g_sasautos2 g_sasautos3 g_sasautos4
28  g_sasautos5 g_sasautos6 g_sasautos7 g_sasautos8 g_sasautos9
29  g_testdata g_refdata g_doc g_error g_warning g_note
30  g_work g_testout g_log g_logfile g_printfile
31  g_testcoverage g_verbose g_crossref g_crossrefsasunit g_rep_encoding
32  ;
33 
34  %LOCAL i;
35 
36  %LET g_target = %sysfunc(pathname(target));
37 
38  %*** Both macvars are dependent on scenario and testcase, values can only be assigned later ***;
39  %LET g_logfile = ;
40  %LET g_printfile = ;
41 
42  %IF %_handleError(&l_macname.
43  ,InvalidTsu
44  ,%_nobs(target.tsu) NE 1
45  ,invalid test database: target.tsu
46  )
47  %THEN %GOTO errexit;
48 
49  %IF %_handleError(&l_macname.
50  ,MissingCas
51  ,NOT %sysfunc(exist(target.cas))
52  ,invalid test database: target.cas
53  )
54  %THEN %GOTO errexit;
55 
56  %IF %_handleError(&l_macname.
57  ,MissingScn
58  ,NOT %sysfunc(exist(target.scn))
59  ,invalid test database: target.scn
60  )
61  %THEN %GOTO errexit;
62 
63  %IF %_handleError(&l_macname.
64  ,MissingTst
65  ,NOT %sysfunc(exist(target.tst))
66  ,invalid test database: target.tst
67  )
68  %THEN %GOTO errexit;
69 
70  DATA _null_;
71  SET target.tsu;
72  call symput ('g_project' , tsu_project);
73  call symput ('g_root' , tsu_root);
74  call symput ('g_sasunitroot' , tsu_sasunitroot);
75  call symput ('g_sasunit' , tsu_sasunit);
76  call symput ('g_sasunit_os' , tsu_sasunit_os);
77  call symput ('g_sasautos' , tsu_sasautos);
78  call symput ('g_sasautos0' , tsu_sasautos);
79  %DO i=1 %TO 9;
80  call symput ("g_sasautos&i" , tsu_sasautos&i);
81  %END;
82  call symput ('g_autoexec' , tsu_autoexec);
83  call symput ('g_sascfg' , tsu_sascfg);
84  call symput ('g_sasuser' , tsu_sasuser);
85  call symput ('g_testdata' , tsu_testdata);
86  call symput ('g_refdata' , tsu_refdata);
87  call symput ('g_doc' , tsu_doc);
88  call symput ('g_testcoverage' , put (tsu_testcoverage, z1.));
89  call symput ('g_verbose' , put (tsu_verbose, z1.));
90  call symput ('g_crossref' , put (tsu_crossref, z1.));
91  call symput ('g_crossrefsasunit', put (tsu_crossrefsasunit, z1.));
92  RUN;
93 
94  %LET g_project = &g_project;
95  %LET g_root = &g_root;
96  %LET g_sasunitroot = %_abspath(&g_root,&g_sasunitroot);
97  %LET g_sasunit = %_abspath(&g_root,&g_sasunit);
98  %LET g_sasunit_os = %_abspath(&g_root,&g_sasunit_os);
99  %LET g_sasautos = %_abspath(&g_root,&g_sasautos);
100  %DO i=0 %TO 9;
101  %LET g_sasautos&i = %_abspath(&g_root,&&g_sasautos&i);
102  %END;
103  %LET g_autoexec = %_abspath(&g_root,&g_autoexec);
104  %LET g_sascfg = %_abspath(&g_root,&g_sascfg);
105  %LET g_sasuser = %_abspath(&g_root,&g_sasuser);
106  %LET g_testdata = %_abspath(&g_root,&g_testdata);
107  %LET g_refdata = %_abspath(&g_root,&g_refdata);
108  %LET g_doc = %_abspath(&g_root,&g_doc);
109  %LET g_testcoverage = &g_testcoverage.;
110  %LET g_rep_encoding = UTF8;
111 
112  %LET g_work = %sysfunc(pathname(work));
113  %LET g_testout = &g_target/tst;
114  %LET g_log = &g_target/log;
115 
116  %_detectSymbols(r_error_symbol=g_error, r_warning_symbol=g_warning, r_note_symbol=g_note);
117 
118  %IF &i_withlibrefs %THEN %DO;
119  LIBNAME testout "&g_testout";
120  FILENAME testout "&g_testout";
121  %IF %length(&g_testdata) %THEN %DO;
122  LIBNAME testdata "&g_testdata";
123  FILENAME testdata "&g_testdata";
124  %LET g_testdata = %sysfunc(pathname(testdata));
125  %END;
126  %IF %length(&g_refdata) %THEN %DO;
127  LIBNAME refdata "&g_refdata";
128  FILENAME refdata "&g_refdata";
129  %LET g_refdata = %sysfunc(pathname(refdata));
130  %END;
131  %IF %length(&g_doc) %THEN %DO;
132  FILENAME doc "&g_doc";
133  %END;
134  %END;
135 
136  OPTIONS MAUTOSOURCE SASAUTOS=(SASAUTOS "&g_sasunit" "&g_sasunit_os"
137  %DO i=0 %TO 9;
138  %IF "&&g_sasautos&i" NE "" %THEN "&&g_sasautos&i";
139  %END; );
140 
141  %_oscmds;
142 
143  %put _global_;
144 
145  %GOTO exit;
146 %errexit:
147  LIBNAME target;
148  %exit:
149 %MEND _loadEnvironment;