Type : CREATION_INTERNE
Le script ne lit pas de données métier externes. Il génère un fichier de log qu'il lit ensuite lui-même (`&ut_work_dir./&ut_log_file.`). Il crée la table `cct` et lit/met à jour la table `_ut_cct_state`, qui est supposée faire partie de l'état interne du framework de test auquel cette macro appartient, et non une source de données externe.
| 1 | %macro ut_run(stmt=, debug=); |
| 2 | /* |
| 3 | Macro to run some SAS code in a controled environement where ERROR and WARNING are not output in the SAS log. |
| 4 | This allows to perform some tests whose result is an ERROR or a WARNING. |
| 5 | stmt: the SAS code to execute. |
| 6 | debug: any non null value enables the debug mode and so disable the SAS log redirection |
| 7 | */ |
| 8 | *-- Exit IF framework state is erroneous --*; |
| 9 | %IF &ut_state. %THEN %DO; |
| 10 | %return; |
| 11 | %END; |
| 12 | |
| 13 | %IF %sysevalf(%superq(debug) =, boolean) %THEN %DO; |
| 14 | *-- This option allows to have SAS log lines up to 256 chars (the max) --*; |
| 15 | option linesize=max; |
| 16 | |
| 17 | *-- Redirect the SAS log --*; |
| 18 | PROC PRINTTO log="&ut_work_dir./&ut_log_file." new; |
| 19 | RUN; |
| 20 | %END; |
| 21 | |
| 22 | *-- Reset warning status --*; |
| 23 | %put WARNING: %str( ); |
| 24 | |
| 25 | *-- Reset error status --*; |
| 26 | %put ERROR: %str( ); |
| 27 | |
| 28 | %let syscc = 0; |
| 29 | |
| 30 | *-- Execute the provided SAS statement --*; |
| 31 | %unquote(&stmt.); |
| 32 | |
| 33 | %IF %sysevalf(%superq(debug) =, boolean) %THEN %DO; |
| 34 | *-- Disable SAS log redirection --*; |
| 35 | PROC PRINTTO; |
| 36 | RUN; |
| 37 | |
| 38 | *-- If code coverage is enabled --*; |
| 39 | %IF &ut_cov. %THEN %DO; |
| 40 | filename i_file "&ut_work_dir./&ut_log_file."; |
| 41 | |
| 42 | *-- Read the input file and find code coverage trackers --*; |
| 43 | DATA cct; |
| 44 | INFILE i_file; |
| 45 | |
| 46 | *-- Read the input file --*; |
| 47 | INPUT; |
| 48 | |
| 49 | *-- Identify code coverage trackers --*; |
| 50 | IF prxmatch('/#cct#\d+#/oi', _infile_) THEN DO; |
| 51 | attrib cct_id STATUS FORMAT=8.; |
| 52 | cct_id = INPUT(prxchange('s/#cct#(\d+)#/$1/oi', -1, _infile_), best.); |
| 53 | STATUS = 1; |
| 54 | OUTPUT; |
| 55 | END; |
| 56 | RUN; |
| 57 | |
| 58 | filename i_file clear; |
| 59 | |
| 60 | PROC SORT DATA=cct nodupkey; BY cct_id; RUN; |
| 61 | |
| 62 | *-- Save code coverage trackers found during that run --*; |
| 63 | PROC SQL noprint undo_policy=none; |
| 64 | create TABLE _ut_cct_state as |
| 65 | select c.cct_id, |
| 66 | c.row_no, |
| 67 | coalesce(c.STATUS, t.STATUS) as STATUS |
| 68 | |
| 69 | from _ut_cct_state c |
| 70 | |
| 71 | left join cct t |
| 72 | on t.cct_id = c.cct_id |
| 73 | |
| 74 | order BY c.cct_id |
| 75 | ; |
| 76 | QUIT; |
| 77 | |
| 78 | PROC DATASETS library=work nolist; |
| 79 | delete cct; |
| 80 | RUN; QUIT; |
| 81 | %END; |
| 82 | %END; |
| 83 | %mend ut_run; |