Class: CTestHook
- Inherits:
-
Mumukit::Templates::FileHook
- Object
- Mumukit::Templates::FileHook
- CTestHook
- Defined in:
- lib/test_hook.rb
Instance Method Summary collapse
- #command_line(filename) ⇒ Object
- #compile_file_content(request) ⇒ Object
- #post_process_file(file, result, status) ⇒ Object
- #tempfile_extension ⇒ Object
- #to_structured_result(result) ⇒ Object
- #transform(examples) ⇒ Object
Instance Method Details
#command_line(filename) ⇒ Object
9 10 11 |
# File 'lib/test_hook.rb', line 9 def command_line(filename) "runcspec #{filename}" end |
#compile_file_content(request) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/test_hook.rb', line 21 def compile_file_content(request) <<EOF #include <cspecs/cspec.h> int main(void) { return report(JSON); } context (mumuki_test) { describe ("Mumuki test") { #{request.extra} #{request.content} #{request.test} } end } EOF end |
#post_process_file(file, result, status) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/test_hook.rb', line 13 def post_process_file(file, result, status) if result.include? '!!TEST FINISHED WITH COMPILATION ERROR!!' [result, :errored] else super end end |
#tempfile_extension ⇒ Object
5 6 7 |
# File 'lib/test_hook.rb', line 5 def tempfile_extension '.c' end |
#to_structured_result(result) ⇒ Object
46 47 48 49 |
# File 'lib/test_hook.rb', line 46 def to_structured_result(result) result = result.split("===========\nJSON REPORT\n===========").last transform(super(result)['examples']) end |
#transform(examples) ⇒ Object
51 52 53 |
# File 'lib/test_hook.rb', line 51 def transform(examples) examples.map { |e| [e['title'], e['status'].to_sym, e['result']] } end |