Class: PhpTestHook

Inherits:
Mumukit::Defaults::TestHook
  • Object
show all
Defined in:
lib/test_hook.rb

Constant Summary collapse

TEST_NAME =
'MumukiSubmissionTest'
PASSED_REGEXP =
/[✔☢] ([^\n]+)/
FAILED_REGEXP =
/✘ ([^\n]+)\n *\│\n *│ ([^イ]+│ \n   )/

Instance Method Summary collapse

Instance Method Details

#run!(request) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/test_hook.rb', line 6

def run!(request)
  result = request.result[:test]

  unless result.include? TEST_NAME
    return [mask_tempfile_references(result.strip), :errored]
  end

  [to_structured_result(result)]
end

#to_structured_result(result) ⇒ Object



16
17
18
19
20
21
# File 'lib/test_hook.rb', line 16

def to_structured_result(result)
  passed_tests = result.scan(PASSED_REGEXP).map { |it| to_passed_result it }
  failed_tests = result.scan(FAILED_REGEXP).map { |it| to_failed_result it }.uniq { |it| it.first }

  passed_tests.concat(failed_tests)
end