[#528] Don't crash when callstack points to another package
Description
Problem: When a cleveland test fails, and the callstack points to a module in a different package (i.e., a package that is not the test suite currently being run), cleveland will try to read the source code from that module and fail.
Solution: if the file cannot be open (e.g. because it's part of a different package), fail gracefully and show only the original error message and callstack.
This command:
stack test baseDAO-ligo-tests --fast --file-watch --test-arguments "--pattern \"\$0 \~ /can drop proposals/\""
Used to fail with:
Main.hs
BaseDAO propose/vote entrypoints tests:
Admin:
can drop proposals: FAIL
Exception: src/BaseDAO/ShareTest/Proposal/Flush.hs: openFile: does not exist (No such file or directory)
Now it fails with:
BaseDAO propose/vote entrypoints tests:
Admin:
can drop proposals: FAIL (0.33s)
Unexpected interpreter error.
Reason: Wrong type for custom error: string
Got: Michelson interpreter failed for contract KT1KCxn8Bv38gUQtEYUCy1hxUUiKbquqsf8j (BaseDAO): Reached FAILWITH instruction with "FAIL_DROP_PROPOSAL_NOT_ACCEPTED"
CallStack (from HasCallStack):
expectCustomError_, called at src/BaseDAO/ShareTest/Proposal/Flush.hs:341:7 in baseDAO-0.1.0.0-6g5Skklv0pIL9LKn9HOR0:BaseDAO.ShareTest.Proposal.Flush
You can try running this command locally against the HEAD of the branch martoon/test-tree-extraction-problem
in baseDAO
Related issue(s)
Resolves #528 (closed)
✅ Checklist for your Merge Request
Related changes (conditional)
-
Tests (see short guidelines)
-
If I added new functionality, I added tests covering it. -
If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
-
-
Documentation
Stylistic guide (mandatory)
-
My commits comply with the following policy. -
My code complies with the style guide.
Edited by Diogo Castro