Skip to content
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
38 changes: 21 additions & 17 deletions source/server/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,28 @@ def run_cyber_dojo_sh(id:, files:, manifest:)

if run[:timed_out]
log(id: id, image_name: image_name, message: 'timed_out', result: utf8_clean(run))
timed_out_result(run)
return timed_out_result(run)
elsif run[:status] != 0 # See comments at end of capture3_with_timeout.rb
log(id: id, image_name: image_name, message: 'faulty', result: utf8_clean(run))
faulty_result(run)
else
colour_result(id, image_name, files_in, run[:stdout])
return faulty_result(run)
end

tgz_out = run[:stdout]
files_out, stdout, stderr, status = files_sss_from(tgz_out)

sss = [stdout['content'], stderr['content'], status['content']]
colour, log_info = *@traffic_light.colour(image_name, *sss)

created, changed = files_delta(files_in, files_out)
result(
stdout, stderr, status['content'],
colour, log_info,
Sandbox.out(at_most(16, created)),
Sandbox.out(changed)
)
rescue Zlib::GzipFile::Error
log(id: id, image_name: image_name, error: 'Zlib::GzipFile::Error')
empty_result(:gzip_error, 'faulty', {})
end

# - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down Expand Up @@ -88,25 +103,14 @@ def threaded_docker_stop_container(id, image_name, container_name)
end
end

def colour_result(id, image_name, files_in, tgz_out)
def files_sss_from(tgz_out)
files_out = TGZ.files(tgz_out).each.with_object({}) do |(filename, content), memo|
memo[filename] = truncated(content)
end
stdout = files_out.delete('tmp/stdout') || truncated('')
stderr = files_out.delete('tmp/stderr') || truncated('')
status = files_out.delete('tmp/status') || truncated('145')
sss = [stdout['content'], stderr['content'], status['content']]
outcome, log_info = *@traffic_light.colour(image_name, *sss)
created, changed = files_delta(files_in, files_out)
result(
stdout, stderr, status['content'],
outcome, log_info,
Sandbox.out(at_most(16, created)),
Sandbox.out(changed)
)
rescue Zlib::GzipFile::Error
log(id: id, image_name: image_name, error: 'Zlib::GzipFile::Error')
empty_result(:gzip_error, 'faulty', {})
[files_out, stdout, stderr, status]
end

# - - - - - - - - - - - - - - - - - - - - -
Expand Down
2 changes: 1 addition & 1 deletion test/server/check_test_metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def table_data
[ 'test.branches.total', test_cov['branches']['total' ], '<=', 0 ],
[ 'test.branches.missed', test_cov['branches']['missed'], '<=', 0 ],
[ nil ],
[ 'code.lines.total', code_cov['lines' ]['total' ], '<=', 559 ],
[ 'code.lines.total', code_cov['lines' ]['total' ], '<=', 560 ],
[ 'code.lines.missed', code_cov['lines' ]['missed'], '<=', 0 ],
[ 'code.branches.total', code_cov['branches']['total' ], '<=', 70 ],
[ 'code.branches.missed', code_cov['branches']['missed'], '<=', 0 ],
Expand Down