This repository was archived by the owner on Sep 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
Stringify errors before processing #124
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cd847ee
Stringify errors before processing
MagiMaster 4e9d0c6
Add missing 2s
MagiMaster c398ea4
Merge remote-tracking branch 'origin/master' into object-errors
MagiMaster 9fbd348
Fix missed merge conflict
MagiMaster ee70a3e
Add some tests of error response
MagiMaster 8920259
Remove unused imports/functions
MagiMaster 25476f5
Merge remote-tracking branch 'origin/master' into object-errors
MagiMaster 99e334c
Update tests/errorTypes.lua
benbrimeyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,7 +196,9 @@ function TestNode:expand() | |
end | ||
setfenv(self.callback, callbackEnv) | ||
|
||
local success, result = xpcall(self.callback, debug.traceback) | ||
local success, result = xpcall(self.callback, function(message) | ||
return debug.traceback(tostring(message), 2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: Might be good to later move this debug.traceback snippet into its own modules for the sake of making sure we keep it DRY, esp since we're passing in "magic" scope There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's probably several such utility functions that could be pulled out. |
||
end) | ||
|
||
if not success then | ||
self.loadError = result | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
local TestEZ = require(script.Parent.Parent.TestEZ) | ||
|
||
local function check(str, test) | ||
local plan = TestEZ.TestPlanner.createPlan({ | ||
{ | ||
-- This function environment hack is needed because the test | ||
-- function is not defined or required from within a test. This | ||
-- shouldn't come up in real tests. | ||
method = function() | ||
setfenv(test, getfenv()) | ||
test() | ||
end, | ||
path = {'errorTypeTests'} | ||
benbrimeyer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}) | ||
|
||
local results = TestEZ.TestRunner.runPlan(plan) | ||
|
||
assert(#results.errors > 0, "Expected some errors, got none.") | ||
for _, err in ipairs(results.errors) do | ||
local find = string.find(err, str) | ||
assert(find, string.format("Expected errors containing [%s], found [%s]", str, err)) | ||
end | ||
end | ||
|
||
return { | ||
["Error message should show up in output"] = function() | ||
check("FOO", function() | ||
error("FOO") | ||
end) | ||
end, | ||
["Erroring with an object should mention the object"] = function() | ||
check("table:", function() | ||
error({}) | ||
end) | ||
end, | ||
["Erroring with an object with __tostring should show the string"] = function() | ||
check("FOO", function() | ||
local obj = setmetatable({}, {__tostring=function() | ||
return "FOO" | ||
end}) | ||
error(obj) | ||
end) | ||
end, | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏