Closed qiemem closed 1 year ago
Oh, how do you put newlines into expected errors in language tests? That will be needed to get tests passing. Or if there's a way to just check a substring of the message.
Oh, how do you put newlines into expected errors in language tests? That will be needed to get tests passing.
Backslash should work: https://github.com/NetLogo/NetLogo/blob/hexy/test/reporters/CommandLambda.txt#L142-L153
Ah of course!
However, still having problems. Here's the test code:
O> ls:ask 0 [ error "hi" ] => ERROR Extension exception: Model 0 (Blank.nlogo) encountered an error at expression 'error "hi"':\
\
hi\
error while observer running ERROR\
called by (anonymous command: [ error "hi" ])\
called by (anonymous command: [ [__lsargs] -> __apply [ error "hi" ] __lsargs ])\
called by procedure __EVALUATOR
but its failing with:
[info] - ls::ls-errors-propogate *** FAILED ***
[info] NormalMode: command: ls:ask 0 [ error "hi" ] Expected "...ession 'error "hi"':[\n\nhi\nerror while observer running ERROR\n called by (anonymous command: [ error "hi" ])\n called by (anonymous command: [ [__lsargs] -> __apply [ error "hi" ] __lsargs ])\n] called by procedur...", but got "...ession 'error "hi"':[
[info]
[info] hi
[info] error while observer running ERROR
[info] called by (anonymous command: [ error "hi" ])
[info] called by (anonymous command: [ [__lsargs] -> __apply [ error "hi" ] __lsargs ])
[info] ] called by procedur..." (AbstractTestLanguage.scala:131)
Hmm, are you using the STACKTRACE
keyword instead of ERROR
? That's what it looks like in the language test parser. Oh I guess that is documented, too. If that keyword doesn't work for you just let me know and we can modify the language test parser to allow multi-line errors in general, too. I think using hard-coded \n
s should work as well, but that's just as a workaround.
Ah! Perfect. Thanks! Should be good to go now.
I realized an alternative strategy here would have been to bubble up an error with a concatenated stack trace rather (by overriding computeRuntimeErrorMessage
, passing in a augmented activation). Might've been a bit cleaner. Probably overengineering it though.
Adds netlogo code stack traces relative to child model code to child model errors:
I would've liked to have had line numbers in there as well, but didn't want to take the time to figure out how to convert from character number to line number, so opted for including the expression with arguments to help disambiguate in larger procedures. Obviously, jumping straight to the source point when GUI would be ideal, but this is still a significant improvement.