Class: RTestHook

Inherits:
Mumukit::Templates::FileHook
  • Object
show all
Defined in:
lib/test_hook.rb

Instance Method Summary collapse

Instance Method Details

#cleanup_raw_result(result) ⇒ Object



45
46
47
# File 'lib/test_hook.rb', line 45

def cleanup_raw_result(result)
  super(result.gsub 'tmpmumuki', '/tmp/mumuki')
end

#command_line(filename) ⇒ Object



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

def command_line(filename)
  %Q{R -q -e testthat::test_file('#{filename}',reporter='junit')} #TODO use
end

#compile_file_content(request) ⇒ Object



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

def compile_file_content(request)
<<R
#{request.extra}
#{request.content}
#{request.test}
R
end

#post_process_file(file, result, status) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/test_hook.rb', line 21

def post_process_file(file, result, status)
  if status.failed?
    [result, :errored]
  else
    super
  end
end

#tempfile_extensionObject



13
14
15
# File 'lib/test_hook.rb', line 13

def tempfile_extension
  '.R'
end

#to_structured_result(result) ⇒ Object



29
30
31
32
# File 'lib/test_hook.rb', line 29

def to_structured_result(result)
  clean_xml = result.gsub(/^>.+$/, '')
  transform(Nokogiri::XML(clean_xml).xpath('//testcase'))
end

#transform(examples) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/test_hook.rb', line 34

def transform(examples)
  examples.map do |it|
    failure = it.at('failure', 'error')
    if failure
      [it['name'].gsub('_', ' '), :failed, failure.content]
    else
      [it['name'].gsub('_', ' '), :passed, '']
    end
  end
end