Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mx_createfile.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mx_createfile macro
4
5 Be sure to run <code>%let mcTestAppLoc=/Public/temp/macrocore;</code> when
6 running in Studio
7
8 <h4> SAS Macros </h4>
9 @li mf_getplatform.sas
10 @li mf_uid.sas
11 @li mfv_existfile.sas
12 @li mm_getstpcode.sas
13 @li mp_assert.sas
14 @li mp_assertscope.sas
15 @li ms_getfile.sas
16 @li mx_createfile.sas
17
18**/
19
20/* create the content to write */
21filename ft15f001 temp;
22data _null_;
23 file ft15f001;
24 put '%let test1=SUCCESS;';
25run;
26
27%let item=%mf_uid();
28
29/* create the file, checking for scope leakage */
30%mp_assertscope(SNAPSHOT)
31%mx_createfile(&mcTestAppLoc/temp/&item, inref=ft15f001)
32%mp_assertscope(COMPARE,
33 desc=Test 1: mx_createfile does not leak scope,
34 ignorelist=MC0_JADP1LEN MC0_JADP2LEN MC0_JADP3LEN MC0_JADPNUM
35 MC0_JADVLEN MC2_JADP1LEN MC2_JADP2LEN MC2_JADPNUM MC2_JADVLEN
36 VIYAPROPERTIES VIYATYPEDEFNAME,
37 outds=work.test_results
38)
39
40/* verify per platform (open code must be wrapped in a macro) */
41%global test1;
42%let test1=FAIL;
43
44%macro check_content();
45 %let platform=%mf_getplatform();
46 %if &platform=SASJS %then %do;
47 /* read the file back from the drive and check the content executes */
48 %ms_getfile(&mcTestAppLoc/temp/&item..sas, outref=testref1)
49 %inc testref1;
50 %end;
51 %else %if &platform=SAS9 or &platform=SASMETA %then %do;
52 /* a type 2 STP now exists in metadata with the code embedded */
53 %mm_getstpcode(tree=&mcTestAppLoc/temp/&item, outref=testref2)
54 %inc testref2;
55 %end;
56 %else %if &platform=SASVIYA %then %do;
57 /* read the file back from SAS Content and check the content executes */
58 filename testref3 filesrvc folderpath="&mcTestAppLoc/temp";
59 %inc testref3(&item)/source2;
60 %end;
61%mend check_content;
62%check_content()
63
64%macro assert_result();
65 %let platform=%mf_getplatform();
66 %if &platform=SASVIYA %then %do;
67 %mp_assert(
68 iftrue=(%mfv_existfile(&mcTestAppLoc/temp/&item)=1),
69 desc=Test 1: VIYA - content file created,
70 outds=work.test_results
71 )
72 %mp_assert(
73 iftrue=(&test1=SUCCESS),
74 desc=Test 2: VIYA - file created with correct content,
75 outds=work.test_results
76 )
77 %end;
78 %else %do;
79 %mp_assert(
80 iftrue=(&test1=SUCCESS),
81 desc=Test 1: file created with correct content (&platform),
82 outds=work.test_results
83 )
84 %end;
85%mend assert_result;
86%assert_result()