Skip to content
This repository was archived by the owner on Sep 14, 2024. It is now read-only.

Fix up tests for roblox-cli #140

Merged
merged 2 commits into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/runner.server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ elseif isRobloxCli then
if errorMessage ~= nil then
print(errorMessage)
end
ProcessService:Exit(statusCode)
ProcessService:ExitAsync(statusCode)
else
-- In Studio, we can just throw an error to get the user's attention

if errorMessage ~= nil then
error(errorMessage, 0)
end
end
end
20 changes: 16 additions & 4 deletions tests/Expectation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,16 @@ return {
expect:throw("foo")
end)


assert(not success, "should fail")
-- Make sure we state the expected error
assert(
message:match("Expected function to throw an error containing \"foo\""),
("Error message does not match:\n%s\n"):format(message)
)
-- Make sure we state the actual error
assert(
message:match("Expected function to throw an error containing \"foo\", but it threw: .+%.lua:%d+: oof"),
message:match(": oof"),
("Error message does not match:\n%s\n"):format(message)
)
end,
Expand Down Expand Up @@ -130,9 +137,14 @@ return {
end)

assert(not success, "should fail")
-- Make sure we state the expected error
assert(
message:match("Expected function to never throw an error containing \"oof\""),
("Error message does not match:\n%s\n"):format(message)
)
-- Make sure we state the actual error
assert(
message:match("Expected function to never throw an error containing \"oof\", "
.. "but it threw: .+%.lua:%d+: foo%-oof"),
message:match(": foo%-oof"),
("Error message does not match:\n%s\n"):format(message)
)
end,
Expand Down Expand Up @@ -255,4 +267,4 @@ return {

assert(success, "should succeed")
end,
}
}