SASUnit Examples  Version 1.5.0
_checkscenario.sas
Go to the documentation of this file.
1 
35 %MACRO _checkScenario(i_examinee =
36  ,i_scn_pre =
37  ,i_dependency =
38  ,i_scenariosToRun =
39  );
40  %LOCAL l_cntObs;
41  %LET l_cntObs = 0;
42 
43  /* Get Scenarios and their names from target.scn */
44  DATA scenarios;
45  IF _n_ = 1 THEN DO;
46  call symput ('l_cntObs',put(cnt_obs, 3.));
47  END;
48  DROP pos;
49  SET target.scn(keep=scn_id scn_path scn_end) nobs=cnt_obs;
50  pos = find(scn_path,'/',-200)+1;
51  scn_name = substr(scn_path,pos);
52  RUN;
53 
54  PROC SQL noprint;
55  create table findScenariosToInsertInDB as
56  select s.scn_id, scn.changed as scn_changed, s.scn_end, scn.membername as name,
57  CASE WHEN scn_id EQ . THEN 1
58  ELSE 0
59  END as insertIntoDB
60  from scenarios as s
61  full join &i_scn_pre as scn
62  on scn.membername=s.scn_name
63  ;
64  QUIT;
65 
66  /* Create scn_id for new scenarios */
67  DATA helper1;
68  retain index &l_cntObs;
69  SET findScenariosToInsertInDB;
70  IF scn_id EQ . THEN DO;
71  index+1;
72  scn_id=index;
73  END;
74  RUN;
75 
76  /* look for units under test not in autocall libraries */
77  PROC SQL noprint;
78  create table noAutocall as
79  select unique cas_scnid
80  from target.cas
81  where cas_auton= .
82  ;
83  /* Map dependencies for each test scenario and check which scenario needs to be run*/
84  create table Dependenciesbyscenario as
85  select h.scn_id, h.name, h.scn_end, h.scn_changed, d.calledByCaller, s.changed as called_changed, h.insertIntoDB,
86  case WHEN scn_end < scn_changed OR scn_end < called_changed OR h.scn_id in (select cas_scnid from noAutocall) THEN 1
87  ELSE 0
88  END as dorun
89  from helper1 as h
90  left join &i_dependency as d on h.name = d.caller
91  left join &i_examinee as s on s.membername=d.calledByCaller
92  order by scn_id;
93  ;
94 
95  /* Condense information to one observation per scenario */
96  create table &i_scenariosToRun as
97  select distinct d1.scn_id, e.membername as name, d1.insertIntoDB, e.filename, (select max(dorun) as dorun
98  from Dependenciesbyscenario as d
99  where e.membername = d.name
100  group by d.name
101  ) as dorun
102  from &i_scn_pre. as e, Dependenciesbyscenario as d1
103  where d1.name = e.membername
104  ;
105  QUIT;
106 
107 %MEND _checkScenario;