SASUnit Examples  Version 1.5.0
_checklog.sas
Go to the documentation of this file.
1 
25 %MACRO _checkLog(i_logfile =
26  ,i_error =
27  ,i_warning =
28  ,r_errors =
29  ,r_warnings =
30  );
31 
32  %LET &r_errors = 999;
33  %LET &r_warnings = 999;
34 
35  DATA _null_;
36 
37  INFILE "&i_logfile" TRUNCOVER end=eof;
38  INPUT logline $char255.;
39 
40  ATTRIB
41  _errorPatternId LENGTH = 8
42  _ignoreErrPatternId LENGTH = 8
43  _warningPatternId LENGTH = 8
44  _errcount LENGTH = 8
45  _warncount LENGTH = 8
46  ;
47  RETAIN
48  _errorPatternId 0
49  _ignoreErrPatternId 0
50  _warningPatternId 0
51  _errcount 0
52  _warncount 0
53  ;
54 
55  IF _n_=1 THEN DO;
56  _errorPatternId = prxparse("/^%UPCASE(&i_error.)[: ]/");
57  _warningPatternId = prxparse("/^%UPCASE(&i_warning.)[: ]/");
58  _ignoreErrPatternId = prxparse("/^ERROR: Errors printed on page/");
59  END;
60 
61  IF prxmatch (_errorPatternId, logline)
62  AND (NOT prxmatch (_ignoreErrPatternId, logline)) THEN DO;
63  _errcount = _errcount+1;
64  END;
65  ELSE IF prxmatch (_warningPatternId, logline) THEN DO;
66  _warncount = _warncount+1;
67  END;
68 
69  IF eof THEN DO;
70  CALL symputx ("&r_errors" , put(_errcount,8.));
71  CALL symputx ("&r_warnings", put(_warncount,8.));
72  END;
73 
74  RUN;
75 
76 %MEND _checkLog;