Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking expected timeouts on check_error too - Fixes mumuki/mumuki-laboratory#1207 #127

Merged
merged 2 commits into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 9 additions & 5 deletions lib/checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ def check_final_board(output, expected)
status = output[:status]
result = output[:result]

is_expected_timeout = result[:finalBoardError] &&
result[:finalBoardError][:reason][:code] == 'timeout' &&
@options[:expect_endless_while]

return if is_expected_timeout
return if is_expected_timeout(result)
assert_not_boom status, result

expected_board = result[:extraBoard]
Expand All @@ -40,6 +36,8 @@ def check_error(output, expected)
status = output[:status]
result = output[:result]

return if is_expected_timeout(result)

fail_with status: :check_error_failed_expected_boom,
result: {
initial: result[:initialBoard],
Expand Down Expand Up @@ -97,6 +95,12 @@ def assert_not_boom(status, result)
} if status == :runtime_error
end

def is_expected_timeout(result)
result[:finalBoardError] &&
result[:finalBoardError][:reason][:code] == 'timeout' &&
@options[:expect_endless_while]
end

def fail_with(error)
fail error.to_json
end
Expand Down
6 changes: 5 additions & 1 deletion lib/precompile_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@ def compile_file_content(request)
def post_process_file(_file, result, status)
if status == :passed
result = result.parse_as_json
status = :aborted if is_timeout? result and !@batch.options[:expect_endless_while]
status = :aborted if is_timeout? result and !expects_timeout?
end

[result, status]
end

private

def expects_timeout?
@batch.options[:expect_endless_while] || @batch.examples.any? { |it| it[:postconditions][:error] == 'timeout' }
end

def is_timeout?(result)
result[0]&.dig(:result, :finalBoardError, :reason, :code) === 'timeout'
end
Expand Down
1 change: 0 additions & 1 deletion lib/render/editor/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@
},

ready: function () {

const resetStatusAfterAborted = () => {
$('#kids-results-aborted').on('hidden.bs.modal', () => {
this.$.runner.isDirty = false;
Expand Down