Skip to content

Commit

Permalink
Update client-tests and demo not to filter runner's results
Browse files Browse the repository at this point in the history
  • Loading branch information
JonJagger committed Jan 14, 2020
1 parent c8ddad4 commit bb55349
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 41 deletions.
9 changes: 7 additions & 2 deletions test_client/src/http_json/responder.rb
Expand Up @@ -6,9 +6,10 @@ module HttpJson

class Responder

def initialize(requester, exception_class)
def initialize(requester, exception_class, options = {})
@requester = requester
@exception_class = exception_class
@options = options
end

# - - - - - - - - - - - - - - - - - - - - -
Expand All @@ -33,7 +34,11 @@ def unpacked(body, path)
unless json.has_key?(path)
fail error_msg(body, "has no key for '#{path}'")
end
json[path]
if @options[:raw]
json
else
json[path]
end
end

# - - - - - - - - - - - - - - - - - - - - -
Expand Down
13 changes: 0 additions & 13 deletions test_client/src/http_json/service.rb

This file was deleted.

6 changes: 4 additions & 2 deletions test_client/src/languages_start_points.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require_relative 'http_json/service'
require_relative 'http_json/requester'
require_relative 'http_json/responder'

class LanguagesStartPoints

Expand All @@ -11,7 +12,8 @@ def initialize(message)
end

def initialize(http)
@http = HttpJson::service(http, 'languages-start-points', 4524, Error)
requester = HttpJson::Requester.new(http, 'languages-start-points', 4524)
@http = HttpJson::Responder.new(requester, Error)
end

def manifest(name)
Expand Down
6 changes: 4 additions & 2 deletions test_client/src/runner.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require_relative 'http_json/service'
require_relative 'http_json/requester'
require_relative 'http_json/responder'

class Runner

Expand All @@ -11,7 +12,8 @@ def initialize(message)
end

def initialize(http)
@http = HttpJson::service(http, 'runner-server', 4597, Error)
requester = HttpJson::Requester.new(http, 'runner-server', 4597)
@http = HttpJson::Responder.new(requester, Error, { raw:true })
end

def alive?
Expand Down
10 changes: 5 additions & 5 deletions test_client/test/alive_test.rb
@@ -1,17 +1,17 @@
require_relative 'test_base'

class ReadyTest < TestBase
class AliveTest < TestBase

def self.hex_prefix
'74C'
end

# - - - - - - - - - - - - - - - - -

test 'CA2', 'ready?' do
ready = runner.ready?
assert ready.is_a?(TrueClass) || ready.is_a?(FalseClass)
assert ready
test 'CA2', 'alive?' do
alive = runner.alive?['alive?']
assert alive.is_a?(TrueClass) || alive.is_a?(FalseClass)
assert alive
end

end
2 changes: 1 addition & 1 deletion test_client/test/large_file_test.rb
Expand Up @@ -37,7 +37,7 @@ def self.hex_prefix
# if test machine is heavily loaded.
if status === 0
diagnostic = [stdout,stderr,status].to_s
assert result['stdout']['truncated'], diagnostic
assert result['run_cyber_dojo_sh']['stdout']['truncated'], diagnostic
end
end

Expand Down
10 changes: 5 additions & 5 deletions test_client/test/ready_test.rb
@@ -1,17 +1,17 @@
require_relative 'test_base'

class AliveTest < TestBase
class ReadyTest < TestBase

def self.hex_prefix
'A86'
end

# - - - - - - - - - - - - - - - - -

test '15D', 'alive?' do
alive = runner.alive?
assert alive.is_a?(TrueClass) || alive.is_a?(FalseClass)
assert alive
test '15D', 'ready?' do
ready = runner.ready?['ready?']
assert ready.is_a?(TrueClass) || ready.is_a?(FalseClass)
assert ready
end

end
2 changes: 1 addition & 1 deletion test_client/test/run_cyber_dojo_sh_test.rb
Expand Up @@ -66,7 +66,7 @@ def self.hex_prefix
'hiker.c' => hiker_c.sub('6 * 9', '6 * 7')
}
})
assert stdout.include?('GCC Code Coverage Report'), :stdout
assert stdout.include?('GCC Code Coverage Report'), :stdout
assert_equal '', stderr
assert_equal 0, status
end
Expand Down
2 changes: 1 addition & 1 deletion test_client/test/sha_test.rb
Expand Up @@ -9,7 +9,7 @@ def self.hex_prefix
# - - - - - - - - - - - - - - - - -

test '882', 'sha' do
sha = runner.sha
sha = runner.sha['sha']
assert sha.is_a?(String)
assert_equal 40, sha.size
sha.each_char do |ch|
Expand Down
14 changes: 7 additions & 7 deletions test_client/test/test_base.rb
Expand Up @@ -68,35 +68,35 @@ def run_cyber_dojo_sh(named_args = {})
attr_reader :result

def stdout
result['stdout']['content']
result['run_cyber_dojo_sh']['stdout']['content']
end

def stderr
result['stderr']['content']
result['run_cyber_dojo_sh']['stderr']['content']
end

def status
result['status']
result['run_cyber_dojo_sh']['status']
end

# - - - - - - - - - - - - - - - - - - - - - - - - - -

def created
result['created']
result['run_cyber_dojo_sh']['created']
end

def deleted
result['deleted']
result['run_cyber_dojo_sh']['deleted']
end

def changed
result['changed']
result['run_cyber_dojo_sh']['changed']
end

# - - - - - - - - - - - - - - - - - - - - - - - - - -

def timed_out?
result['timed_out']
result['run_cyber_dojo_sh']['timed_out']
end

# - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down
4 changes: 2 additions & 2 deletions test_client/test/util/check_test_results.rb
Expand Up @@ -116,8 +116,8 @@ def get_test_log_stats
[ 'duration(test)[s]', test_duration, '<=', 50 ],
[ 'coverage(app)[%]', app_coverage, '==', 100 ],
[ 'coverage(test)[%]', test_coverage, '==', 100 ],
[ 'lines(test)/lines(app)', f2(line_ratio), '>=', 3.1 ],
[ 'hits(app)/hits(test)', f2(hits_ratio), '>=', 1.2 ],
[ 'lines(test)/lines(app)', f2(line_ratio), '>=', 2.7 ],
[ 'hits(app)/hits(test)', f2(hits_ratio), '>=', 2.2 ],
]

# - - - - - - - - - - - - - - - - - - - - - - -
Expand Down

0 comments on commit bb55349

Please sign in to comment.