fix(mpe_assert_abort): size the capture buffer for the whole message
Build / Build-and-ng-test (pull_request) Successful in 4m56s
Lighthouse Checks / lighthouse (pull_request) Successful in 17m45s
Build / Build-and-test-development (pull_request) Successful in 27m49s

The strip cuts the message at the "Log Extract:" marker, and got was declared
$256 - so a message whose text pushed the marker past 256 characters was never
stripped, and the exact comparison then failed on the escaped tail. got is now
the same width as line ($32767).

Covered by a new case in mpe_assert_abort.test.sas: an abort whose message runs
past 256 characters, asserted in full. It fails against the $256 buffer and
passes once got is widened, so the width is pinned rather than assumed.

mpe_assert_abort: PASS, full suite 64/64, rebuilt with sasjs cbd.
This commit is contained in:
dc committed 2026-10-30 20:01:19 +00:00
1 parent 8b426c27fd
commit 5d32de9df9
2 files changed
+42 -4

No files matched your search

+4 -1
View File
@@ -57,7 +57,10 @@
%end;
%else %do;
data _null_;
length line $32767 got $256;
/* got is the same width as line: the strip of the appended log extract can
only fire if the whole message reached the buffer, and a hook message can
run past 256 characters */
length line $32767 got $32767;
retain prxid 0 inabort 0 found 0 abortseen 0;
if _n_=1 then prxid=prxparse('/"MSG" *: *"([^"]*)"/');
infile &outref end=eof lrecl=32767;
+38 -3
View File
@@ -4,8 +4,9 @@
@details The macro decides PASS/FAIL by scanning the child's response text, so
the cases that matter can be built as files instead of services: an abort with
the expected message, an abort with a different one, no abort at all, and a
fileref the child never wrote to.
the expected message, an abort with a different one, no abort at all, a
fileref the child never wrote to, and a message long enough to test the width
of the capture buffer.
Each case asserts on the PASS/FAIL the macro recorded, so a regression in the
scan fails here rather than silently passing an abort assertion in a service
@@ -101,7 +102,31 @@ run;
)
/**
* Test 5 - the recorded results
* Test 5 - a message longer than the capture buffer is compared in full
*
* The strip of the appended log extract only works if the whole message made
* it into the capture buffer, so this case is longer than 256 characters -
* the width the buffer had while the strip was added.
*/
%let f5=%mf_getuniquefileref();
%let longmsg=;
data _null_;
file &f5 termstr=crlf;
length msgtxt $1000;
msgtxt=repeat('a clause that runs on ',30);
put '{"sasjsAbort": [{"MSG": "' msgtxt +(-1) '\n\nLog Extract:\nNOTE: a log line"}]}';
call symputx('longmsg',msgtxt,'l');
run;
%mpe_assert_abort(
desc=an abort with a message past the capture buffer,
outref=&f5,
msg=%superq(longmsg),
outds=&rc_long
)
/**
* Test 6 - the recorded results
*/
@@ -121,6 +146,10 @@ data _null_;
set &rc_noref;
call symputx('res_noref',test_result,'g');
run;
data _null_;
set &rc_long;
call symputx('res_long',test_result,'g');
run;
%mp_assert(
iftrue=("&res_any"="PASS"),
@@ -143,6 +172,12 @@ run;
%mp_assert(
iftrue=("&res_long"="PASS"),
desc=%str(Checking an abort message longer than the capture buffer matches in full),
outds=work.test_results
)
%mp_assert(
iftrue=("&res_noref"="FAIL"),
desc=%str(Checking an unassigned outref fails the assertion, not the step),