From a32ea285d758c4124758b390da47a16f27da51e9 Mon Sep 17 00:00:00 2001 From: Rodrigo Alfonso Date: Wed, 3 Oct 2018 02:01:47 -0300 Subject: [PATCH 1/2] Checking expected timeouts on check_error too --- lib/checker.rb | 14 +++++++++----- lib/render/editor/editor.html | 1 - 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/checker.rb b/lib/checker.rb index 6773511..007637f 100644 --- a/lib/checker.rb +++ b/lib/checker.rb @@ -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] @@ -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], @@ -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 diff --git a/lib/render/editor/editor.html b/lib/render/editor/editor.html index ac11810..bfa7746 100644 --- a/lib/render/editor/editor.html +++ b/lib/render/editor/editor.html @@ -401,7 +401,6 @@ }, ready: function () { - const resetStatusAfterAborted = () => { $('#kids-results-aborted').on('hidden.bs.modal', () => { this.$.runner.isDirty = false; From aa8b76d176f9208b322e38d92c79c5f7af48136a Mon Sep 17 00:00:00 2001 From: Rodrigo Alfonso Date: Thu, 4 Oct 2018 00:40:42 -0300 Subject: [PATCH 2/2] Not returning :aborted if any precondition checks for timeouts --- lib/precompile_hook.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/precompile_hook.rb b/lib/precompile_hook.rb index 571633c..4ed72ae 100644 --- a/lib/precompile_hook.rb +++ b/lib/precompile_hook.rb @@ -47,7 +47,7 @@ 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] @@ -55,6 +55,10 @@ def post_process_file(_file, result, status) 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