ciat 0.4.9 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ciat.rb +1 -2
 - data/lib/ciat/{test_file.rb → ciat_file.rb} +21 -9
 - data/lib/ciat/erb_helpers.rb +6 -1
 - data/lib/ciat/feedback/feedback_counter.rb +11 -19
 - data/lib/ciat/feedback/return_status.rb +6 -2
 - data/lib/ciat/feedback/standard_output.rb +7 -2
 - data/lib/ciat/processors/compilation_interpreter.rb +20 -7
 - data/lib/ciat/processors/compiler.rb +38 -15
 - data/lib/ciat/processors/interpreter.rb +28 -7
 - data/lib/ciat/processors/java.rb +2 -8
 - data/lib/ciat/processors/parrot.rb +0 -3
 - data/lib/ciat/subresult.rb +14 -4
 - data/lib/ciat/subtest.rb +83 -0
 - data/lib/ciat/suite.rb +9 -9
 - data/lib/ciat/suite_builder.rb +5 -5
 - data/lib/ciat/test.rb +36 -28
 - data/lib/ciat/test_result.rb +2 -2
 - data/lib/ciat/traffic_light.rb +5 -14
 - data/lib/data/ciat.css +14 -2
 - data/lib/data/elements.yml +8 -2
 - data/lib/templates/detail_row.html.erb +10 -4
 - data/lib/templates/report.html.erb +5 -5
 - data/lib/templates/summary_row.html.erb +5 -3
 - data/spec/ciat/{test_file_spec.rb → ciat_file_spec.rb} +51 -19
 - data/spec/ciat/erb_helpers_spec.rb +8 -13
 - data/spec/ciat/feedback/feedback_counter_spec.rb +37 -57
 - data/spec/ciat/feedback/return_status_spec.rb +67 -61
 - data/spec/ciat/feedback/standard_output_spec.rb +21 -15
 - data/spec/ciat/processors/compilation_interpreter_spec.rb +12 -0
 - data/spec/ciat/processors/compiler_spec.rb +12 -0
 - data/spec/ciat/processors/interpreter_spec.rb +12 -0
 - data/spec/ciat/processors/java_spec.rb +0 -10
 - data/spec/ciat/processors/parrot_spec.rb +0 -10
 - data/spec/ciat/processors/shared_examples_for_element_names.rb +27 -0
 - data/spec/ciat/rake_task_spec.rb +65 -0
 - data/spec/ciat/subresult_spec.rb +13 -12
 - data/spec/ciat/subtest_spec.rb +199 -0
 - data/spec/ciat/suite_builder_spec.rb +17 -17
 - data/spec/ciat/suite_spec.rb +13 -13
 - data/spec/ciat/test_result_spec.rb +36 -0
 - data/spec/ciat/test_spec.rb +73 -83
 - data/spec/ciat/traffic_light_spec.rb +21 -31
 - data/spec/spec_helper.rb +16 -53
 - data/spec/templates/detail_row/elements_html_erb_spec.rb +3 -4
 - data/spec/templates/detail_row_html_erb_spec.rb +84 -23
 - data/spec/templates/elements/diff_html_erb_spec.rb +5 -3
 - data/spec/templates/summary_row_html_erb_spec.rb +21 -14
 - metadata +13 -7
 - data/lib/ciat/processors/basic_processing.rb +0 -55
 - data/spec/ciat/processors/basic_processing_spec.rb +0 -146
 
    
        data/lib/ciat.rb
    CHANGED
    
    | 
         @@ -10,11 +10,10 @@ require 'ciat/traffic_light' 
     | 
|
| 
       10 
10 
     | 
    
         
             
            require 'ciat/suite'
         
     | 
| 
       11 
11 
     | 
    
         
             
            require 'ciat/test'
         
     | 
| 
       12 
12 
     | 
    
         
             
            require 'ciat/test_element'
         
     | 
| 
       13 
     | 
    
         
            -
            require 'ciat/ 
     | 
| 
      
 13 
     | 
    
         
            +
            require 'ciat/ciat_file'
         
     | 
| 
       14 
14 
     | 
    
         
             
            require 'ciat/feedback/standard_output'
         
     | 
| 
       15 
15 
     | 
    
         
             
            require 'ciat/feedback/html_feedback'
         
     | 
| 
       16 
16 
     | 
    
         
             
            require 'ciat/differs/html_differ'
         
     | 
| 
       17 
     | 
    
         
            -
            require 'ciat/processors/basic_processing'
         
     | 
| 
       18 
17 
     | 
    
         
             
            require 'ciat/processors/compiler'
         
     | 
| 
       19 
18 
     | 
    
         
             
            require 'ciat/processors/interpreter'
         
     | 
| 
       20 
19 
     | 
    
         
             
            require 'ciat/processors/compilation_interpreter'
         
     | 
| 
         @@ -1,23 +1,35 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            class CIAT:: 
     | 
| 
      
 1 
     | 
    
         
            +
            class CIAT::CiatFile #:nodoc:all
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
              def initialize( 
     | 
| 
       4 
     | 
    
         
            -
                unless File.exists?( 
     | 
| 
       5 
     | 
    
         
            -
                  raise IOError.new( 
     | 
| 
      
 3 
     | 
    
         
            +
              def initialize(ciat_file, output_folder)
         
     | 
| 
      
 4 
     | 
    
         
            +
                unless File.exists?(ciat_file)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  raise IOError.new(ciat_file + " does not exist")
         
     | 
| 
       6 
6 
     | 
    
         
             
                end
         
     | 
| 
       7 
     | 
    
         
            -
                @ 
     | 
| 
      
 7 
     | 
    
         
            +
                @ciat_file = ciat_file
         
     | 
| 
       8 
8 
     | 
    
         
             
                @output_folder = output_folder
         
     | 
| 
       9 
9 
     | 
    
         
             
              end
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
      
 11 
     | 
    
         
            +
              def elements
         
     | 
| 
      
 12 
     | 
    
         
            +
                @elements ||= process
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
              
         
     | 
| 
      
 15 
     | 
    
         
            +
              def element(*names)
         
     | 
| 
      
 16 
     | 
    
         
            +
                elements[names.compact.join("_").to_sym]
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
              
         
     | 
| 
      
 19 
     | 
    
         
            +
              def element?(*names)
         
     | 
| 
      
 20 
     | 
    
         
            +
                elements.has_key?(names.compact.join("_").to_sym)
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       11 
23 
     | 
    
         
             
              def filename(*modifiers)
         
     | 
| 
       12 
24 
     | 
    
         
             
                if modifiers == [:ciat]
         
     | 
| 
       13 
     | 
    
         
            -
                  @ 
     | 
| 
      
 25 
     | 
    
         
            +
                  @ciat_file
         
     | 
| 
       14 
26 
     | 
    
         
             
                else
         
     | 
| 
       15 
27 
     | 
    
         
             
                  File.join(@output_folder, [stub, *modifiers].compact.join("_"))
         
     | 
| 
       16 
28 
     | 
    
         
             
                end
         
     | 
| 
       17 
29 
     | 
    
         
             
              end
         
     | 
| 
       18 
30 
     | 
    
         | 
| 
       19 
31 
     | 
    
         
             
              def grouping
         
     | 
| 
       20 
     | 
    
         
            -
                File.dirname(@ 
     | 
| 
      
 32 
     | 
    
         
            +
                File.dirname(@ciat_file)
         
     | 
| 
       21 
33 
     | 
    
         
             
              end
         
     | 
| 
       22 
34 
     | 
    
         | 
| 
       23 
35 
     | 
    
         
             
              def process #:nodoc:
         
     | 
| 
         @@ -51,7 +63,7 @@ class CIAT::TestFile #:nodoc:all 
     | 
|
| 
       51 
63 
     | 
    
         
             
              private
         
     | 
| 
       52 
64 
     | 
    
         | 
| 
       53 
65 
     | 
    
         
             
              def read
         
     | 
| 
       54 
     | 
    
         
            -
                File.readlines(@ 
     | 
| 
      
 66 
     | 
    
         
            +
                File.readlines(@ciat_file)
         
     | 
| 
       55 
67 
     | 
    
         
             
              end  
         
     | 
| 
       56 
68 
     | 
    
         | 
| 
       57 
69 
     | 
    
         
             
              def empty_elements_hash
         
     | 
| 
         @@ -61,6 +73,6 @@ class CIAT::TestFile #:nodoc:all 
     | 
|
| 
       61 
73 
     | 
    
         
             
              end
         
     | 
| 
       62 
74 
     | 
    
         | 
| 
       63 
75 
     | 
    
         
             
              def stub
         
     | 
| 
       64 
     | 
    
         
            -
                @ 
     | 
| 
      
 76 
     | 
    
         
            +
                @ciat_file.gsub(File.extname(@ciat_file), "")
         
     | 
| 
       65 
77 
     | 
    
         
             
              end
         
     | 
| 
       66 
78 
     | 
    
         
             
            end
         
     | 
    
        data/lib/ciat/erb_helpers.rb
    CHANGED
    
    | 
         @@ -11,6 +11,7 @@ module CIAT::ERBHelpers 
     | 
|
| 
       11 
11 
     | 
    
         
             
              	when light.yellow? then "ERROR"
         
     | 
| 
       12 
12 
     | 
    
         
             
              	when light.green? then "passed"
         
     | 
| 
       13 
13 
     | 
    
         
             
              	when light.unset? then "n/a"
         
     | 
| 
      
 14 
     | 
    
         
            +
              	when light.unneeded? then "unneeded"
         
     | 
| 
       14 
15 
     | 
    
         
             
            	  else
         
     | 
| 
       15 
16 
     | 
    
         
             
            	    raise "cannot turn #{light} into word"
         
     | 
| 
       16 
17 
     | 
    
         
             
              	end
         
     | 
| 
         @@ -18,7 +19,7 @@ module CIAT::ERBHelpers 
     | 
|
| 
       18 
19 
     | 
    
         | 
| 
       19 
20 
     | 
    
         
             
              # Turns a traffic light in a sentence wrapped in a classed +span+.
         
     | 
| 
       20 
21 
     | 
    
         
             
              def light_to_sentence(prefix, light)
         
     | 
| 
       21 
     | 
    
         
            -
              	"<span class=\"#{light. 
     | 
| 
      
 22 
     | 
    
         
            +
              	"<span class=\"#{light.color}\">#{prefix} " +
         
     | 
| 
       22 
23 
     | 
    
         
             
              	case
         
     | 
| 
       23 
24 
     | 
    
         
             
              	when light.red? then "failed"
         
     | 
| 
       24 
25 
     | 
    
         
             
              	when light.yellow? then "errored"
         
     | 
| 
         @@ -29,6 +30,10 @@ module CIAT::ERBHelpers 
     | 
|
| 
       29 
30 
     | 
    
         
             
              	end +
         
     | 
| 
       30 
31 
     | 
    
         
             
              	".</span>"
         
     | 
| 
       31 
32 
     | 
    
         
             
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
              
         
     | 
| 
      
 34 
     | 
    
         
            +
              def filename_to_id(filename)
         
     | 
| 
      
 35 
     | 
    
         
            +
                filename.gsub(/[\/\-.]/, "_")
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
       32 
37 
     | 
    
         | 
| 
       33 
38 
     | 
    
         
             
              # Capitalizes string as a title.
         
     | 
| 
       34 
39 
     | 
    
         
             
              def title(text)
         
     | 
| 
         @@ -4,26 +4,23 @@ module CIAT 
     | 
|
| 
       4 
4 
     | 
    
         
             
                # progress of a CIAT::Suite run.
         
     | 
| 
       5 
5 
     | 
    
         
             
                class FeedbackCounter
         
     | 
| 
       6 
6 
     | 
    
         
             
                  def initialize
         
     | 
| 
       7 
     | 
    
         
            -
                    @ 
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
                    @counts = {
         
     | 
| 
      
 8 
     | 
    
         
            +
                      CIAT::TrafficLight::RED => 0,
         
     | 
| 
      
 9 
     | 
    
         
            +
                      CIAT::TrafficLight::YELLOW => 0,
         
     | 
| 
      
 10 
     | 
    
         
            +
                      CIAT::TrafficLight::GREEN => 0,
         
     | 
| 
      
 11 
     | 
    
         
            +
                      CIAT::TrafficLight::UNSET => 0,
         
     | 
| 
      
 12 
     | 
    
         
            +
                      CIAT::TrafficLight::UNNEEDED => 0
         
     | 
| 
      
 13 
     | 
    
         
            +
                    }
         
     | 
| 
       9 
14 
     | 
    
         
             
                  end
         
     | 
| 
       10 
15 
     | 
    
         | 
| 
       11 
16 
     | 
    
         
             
                  def error_count
         
     | 
| 
       12 
     | 
    
         
            -
                    @ 
     | 
| 
      
 17 
     | 
    
         
            +
                    @counts[CIAT::TrafficLight::YELLOW]
         
     | 
| 
       13 
18 
     | 
    
         
             
                  end
         
     | 
| 
       14 
19 
     | 
    
         | 
| 
       15 
20 
     | 
    
         
             
                  def failure_count
         
     | 
| 
       16 
     | 
    
         
            -
                    @ 
     | 
| 
      
 21 
     | 
    
         
            +
                    @counts[CIAT::TrafficLight::RED]
         
     | 
| 
       17 
22 
     | 
    
         
             
                  end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                  def increment_error_count
         
     | 
| 
       20 
     | 
    
         
            -
                    @error_count += 1
         
     | 
| 
       21 
     | 
    
         
            -
                  end
         
     | 
| 
       22 
     | 
    
         
            -
                  
         
     | 
| 
       23 
     | 
    
         
            -
                  def increment_failure_count
         
     | 
| 
       24 
     | 
    
         
            -
                    @failure_count += 1
         
     | 
| 
       25 
     | 
    
         
            -
                  end
         
     | 
| 
       26 
     | 
    
         
            -
                  
         
     | 
| 
      
 23 
     | 
    
         
            +
                        
         
     | 
| 
       27 
24 
     | 
    
         
             
                  def pre_tests(suite)
         
     | 
| 
       28 
25 
     | 
    
         
             
                    nil
         
     | 
| 
       29 
26 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -33,12 +30,7 @@ module CIAT 
     | 
|
| 
       33 
30 
     | 
    
         
             
                  end
         
     | 
| 
       34 
31 
     | 
    
         | 
| 
       35 
32 
     | 
    
         
             
                  def report_subresult(subresult)
         
     | 
| 
       36 
     | 
    
         
            -
                     
     | 
| 
       37 
     | 
    
         
            -
                    when :red
         
     | 
| 
       38 
     | 
    
         
            -
                      increment_failure_count
         
     | 
| 
       39 
     | 
    
         
            -
                    when :yellow
         
     | 
| 
       40 
     | 
    
         
            -
                      increment_error_count
         
     | 
| 
       41 
     | 
    
         
            -
                    end
         
     | 
| 
      
 33 
     | 
    
         
            +
                    @counts[subresult.light] = @counts[subresult.light] + 1
         
     | 
| 
       42 
34 
     | 
    
         
             
                  end
         
     | 
| 
       43 
35 
     | 
    
         
             
                end
         
     | 
| 
       44 
36 
     | 
    
         
             
              end
         
     | 
| 
         @@ -11,11 +11,15 @@ module CIAT::Feedback 
     | 
|
| 
       11 
11 
     | 
    
         
             
                  end
         
     | 
| 
       12 
12 
     | 
    
         
             
                end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
                def report_subresult( 
     | 
| 
       15 
     | 
    
         
            -
                  @failure ||=  
     | 
| 
      
 14 
     | 
    
         
            +
                def report_subresult(subresult)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  @failure ||= subresult_failure?(subresult, subresult.light)
         
     | 
| 
       16 
16 
     | 
    
         
             
                end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
                private
         
     | 
| 
      
 19 
     | 
    
         
            +
                def subresult_failure?(subresult, light)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  light.yellow? || light.red?
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
                
         
     | 
| 
       19 
23 
     | 
    
         
             
                def failure?
         
     | 
| 
       20 
24 
     | 
    
         
             
                  @failure
         
     | 
| 
       21 
25 
     | 
    
         
             
                end
         
     | 
| 
         @@ -3,7 +3,12 @@ module CIAT 
     | 
|
| 
       3 
3 
     | 
    
         
             
                # This feedback class sends some simple messages to the screen about the
         
     | 
| 
       4 
4 
     | 
    
         
             
                # progress of a CIAT::Suite run.
         
     | 
| 
       5 
5 
     | 
    
         
             
                class StandardOutput
         
     | 
| 
       6 
     | 
    
         
            -
                  LIGHT_OUTPUTS = { 
     | 
| 
      
 6 
     | 
    
         
            +
                  LIGHT_OUTPUTS = {
         
     | 
| 
      
 7 
     | 
    
         
            +
                    CIAT::TrafficLight::GREEN => ".", 
         
     | 
| 
      
 8 
     | 
    
         
            +
                    CIAT::TrafficLight::RED => "F", 
         
     | 
| 
      
 9 
     | 
    
         
            +
                    CIAT::TrafficLight::YELLOW => "E", 
         
     | 
| 
      
 10 
     | 
    
         
            +
                    CIAT::TrafficLight::UNSET => "-",
         
     | 
| 
      
 11 
     | 
    
         
            +
                    CIAT::TrafficLight::UNNEEDED => "." }
         
     | 
| 
       7 
12 
     | 
    
         | 
| 
       8 
13 
     | 
    
         
             
                  def initialize(counter)
         
     | 
| 
       9 
14 
     | 
    
         
             
                    @counter = counter
         
     | 
| 
         @@ -22,7 +27,7 @@ module CIAT 
     | 
|
| 
       22 
27 
     | 
    
         
             
                  end
         
     | 
| 
       23 
28 
     | 
    
         | 
| 
       24 
29 
     | 
    
         
             
                  def report_subresult(processor)
         
     | 
| 
       25 
     | 
    
         
            -
                    putc LIGHT_OUTPUTS[processor.light 
     | 
| 
      
 30 
     | 
    
         
            +
                    putc LIGHT_OUTPUTS[processor.light]
         
     | 
| 
       26 
31 
     | 
    
         
             
                  end
         
     | 
| 
       27 
32 
     | 
    
         
             
                end
         
     | 
| 
       28 
33 
     | 
    
         
             
              end
         
     | 
| 
         @@ -1,11 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class CIAT::Processors::CompilationInterpreter
         
     | 
| 
       2 
     | 
    
         
            -
              def  
     | 
| 
       3 
     | 
    
         
            -
                 
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                }
         
     | 
| 
      
 2 
     | 
    
         
            +
              def relevant_elements(color, path)
         
     | 
| 
      
 3 
     | 
    
         
            +
                element_name_hash[color]
         
     | 
| 
      
 4 
     | 
    
         
            +
              end
         
     | 
| 
      
 5 
     | 
    
         
            +
              
         
     | 
| 
      
 6 
     | 
    
         
            +
              def happy_path_element
         
     | 
| 
      
 7 
     | 
    
         
            +
                :execution
         
     | 
| 
       9 
8 
     | 
    
         
             
              end
         
     | 
| 
       10 
9 
     | 
    
         | 
| 
       11 
10 
     | 
    
         
             
              def input_name
         
     | 
| 
         @@ -15,4 +14,18 @@ class CIAT::Processors::CompilationInterpreter 
     | 
|
| 
       15 
14 
     | 
    
         
             
              def output_name
         
     | 
| 
       16 
15 
     | 
    
         
             
                :execution
         
     | 
| 
       17 
16 
     | 
    
         
             
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
              
         
     | 
| 
      
 18 
     | 
    
         
            +
              def error_name
         
     | 
| 
      
 19 
     | 
    
         
            +
                :execution_error
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
              
         
     | 
| 
      
 22 
     | 
    
         
            +
              private
         
     | 
| 
      
 23 
     | 
    
         
            +
              def element_name_hash
         
     | 
| 
      
 24 
     | 
    
         
            +
                {
         
     | 
| 
      
 25 
     | 
    
         
            +
                  CIAT::TrafficLight::GREEN => [:compilation_generated, :execution_generated],
         
     | 
| 
      
 26 
     | 
    
         
            +
                  CIAT::TrafficLight::YELLOW => [:compilation_generated, :execution_error_generated],
         
     | 
| 
      
 27 
     | 
    
         
            +
                  CIAT::TrafficLight::RED => [:compilation_generated, :execution_diff],
         
     | 
| 
      
 28 
     | 
    
         
            +
                  CIAT::TrafficLight::UNSET => []
         
     | 
| 
      
 29 
     | 
    
         
            +
                }
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
       18 
31 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,18 +1,41 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
       3 
     | 
    
         
            -
                 
     | 
| 
       4 
     | 
    
         
            -
                   
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            module CIAT::Processors
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Compiler
         
     | 
| 
      
 3 
     | 
    
         
            +
                def relevant_elements(color, path)
         
     | 
| 
      
 4 
     | 
    
         
            +
                  element_name_hash[path][color]
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
              
         
     | 
| 
      
 7 
     | 
    
         
            +
                def happy_path_element
         
     | 
| 
      
 8 
     | 
    
         
            +
                  :compilation
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
                def input_name
         
     | 
| 
      
 12 
     | 
    
         
            +
                  :source
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                def output_name
         
     | 
| 
      
 16 
     | 
    
         
            +
                  :compilation
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              
         
     | 
| 
      
 19 
     | 
    
         
            +
                def error_name
         
     | 
| 
      
 20 
     | 
    
         
            +
                  :compilation_error
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                private
         
     | 
| 
      
 24 
     | 
    
         
            +
                def element_name_hash
         
     | 
| 
      
 25 
     | 
    
         
            +
                  {
         
     | 
| 
      
 26 
     | 
    
         
            +
                    :happy => {
         
     | 
| 
      
 27 
     | 
    
         
            +
                      CIAT::TrafficLight::GREEN => [:source, :compilation_generated],
         
     | 
| 
      
 28 
     | 
    
         
            +
                      CIAT::TrafficLight::YELLOW => [:source, :compilation_generated, :compilation_error_generated],
         
     | 
| 
      
 29 
     | 
    
         
            +
                      CIAT::TrafficLight::RED => [:source, :compilation_diff],
         
     | 
| 
      
 30 
     | 
    
         
            +
                      CIAT::TrafficLight::UNSET => []
         
     | 
| 
      
 31 
     | 
    
         
            +
                    },
         
     | 
| 
      
 32 
     | 
    
         
            +
                    :sad => {
         
     | 
| 
      
 33 
     | 
    
         
            +
                      CIAT::TrafficLight::GREEN => [:source, :compilation_error_generated],
         
     | 
| 
      
 34 
     | 
    
         
            +
                      CIAT::TrafficLight::YELLOW => [:source, :compilation_generated, :compilation_error_generated],
         
     | 
| 
      
 35 
     | 
    
         
            +
                      CIAT::TrafficLight::RED => [:source, :compilation_error_diff, :compilation_generated],
         
     | 
| 
      
 36 
     | 
    
         
            +
                      CIAT::TrafficLight::UNSET => []
         
     | 
| 
      
 37 
     | 
    
         
            +
                    }
         
     | 
| 
      
 38 
     | 
    
         
            +
                  }
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
       17 
40 
     | 
    
         
             
              end
         
     | 
| 
       18 
     | 
    
         
            -
            end
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,13 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class CIAT::Processors::Interpreter
         
     | 
| 
       2 
     | 
    
         
            -
              def  
     | 
| 
       3 
     | 
    
         
            -
                 
     | 
| 
       4 
     | 
    
         
            -
                  :green => [:source, :command_line, :execution_generated],
         
     | 
| 
       5 
     | 
    
         
            -
                  :yellow => [:source, :command_line, :execution_error],
         
     | 
| 
       6 
     | 
    
         
            -
                  :red => [:source, :command_line, :execution_diff],
         
     | 
| 
       7 
     | 
    
         
            -
                  :unset => []
         
     | 
| 
       8 
     | 
    
         
            -
                }
         
     | 
| 
      
 2 
     | 
    
         
            +
              def relevant_elements(color, path)
         
     | 
| 
      
 3 
     | 
    
         
            +
                element_name_hash[path][color]
         
     | 
| 
       9 
4 
     | 
    
         
             
              end
         
     | 
| 
       10 
5 
     | 
    
         | 
| 
      
 6 
     | 
    
         
            +
              def happy_path_element
         
     | 
| 
      
 7 
     | 
    
         
            +
                :execution
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
       11 
10 
     | 
    
         
             
              def input_name
         
     | 
| 
       12 
11 
     | 
    
         
             
                :source
         
     | 
| 
       13 
12 
     | 
    
         
             
              end
         
     | 
| 
         @@ -15,4 +14,26 @@ class CIAT::Processors::Interpreter 
     | 
|
| 
       15 
14 
     | 
    
         
             
              def output_name
         
     | 
| 
       16 
15 
     | 
    
         
             
                :execution
         
     | 
| 
       17 
16 
     | 
    
         
             
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
              
         
     | 
| 
      
 18 
     | 
    
         
            +
              def error_name
         
     | 
| 
      
 19 
     | 
    
         
            +
                :execution_error
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
              
         
     | 
| 
      
 22 
     | 
    
         
            +
              private
         
     | 
| 
      
 23 
     | 
    
         
            +
              def element_name_hash
         
     | 
| 
      
 24 
     | 
    
         
            +
                {
         
     | 
| 
      
 25 
     | 
    
         
            +
                  :happy => {
         
     | 
| 
      
 26 
     | 
    
         
            +
                    CIAT::TrafficLight::GREEN => [:source, :command_line, :execution_generated],
         
     | 
| 
      
 27 
     | 
    
         
            +
                    CIAT::TrafficLight::YELLOW => [:source, :command_line, :execution_generated, :execution_error_generated],
         
     | 
| 
      
 28 
     | 
    
         
            +
                    CIAT::TrafficLight::RED => [:source, :command_line, :execution_diff, :execution_error_generated],
         
     | 
| 
      
 29 
     | 
    
         
            +
                    CIAT::TrafficLight::UNSET => []
         
     | 
| 
      
 30 
     | 
    
         
            +
                  },
         
     | 
| 
      
 31 
     | 
    
         
            +
                  :sad => {
         
     | 
| 
      
 32 
     | 
    
         
            +
                    CIAT::TrafficLight::GREEN => [:source, :command_line, :execution_error_generated],
         
     | 
| 
      
 33 
     | 
    
         
            +
                   CIAT::TrafficLight::YELLOW => [:source, :command_line, :execution_error_generated, :execution_generated],
         
     | 
| 
      
 34 
     | 
    
         
            +
                    CIAT::TrafficLight::RED => [:source, :command_line, :execution_error_diff, :execution_generated],
         
     | 
| 
      
 35 
     | 
    
         
            +
                    CIAT::TrafficLight::UNSET => []
         
     | 
| 
      
 36 
     | 
    
         
            +
                  }
         
     | 
| 
      
 37 
     | 
    
         
            +
                }
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
       18 
39 
     | 
    
         
             
            end
         
     | 
    
        data/lib/ciat/processors/java.rb
    CHANGED
    
    | 
         @@ -1,19 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module CIAT
         
     | 
| 
       2 
2 
     | 
    
         
             
              module Processors
         
     | 
| 
       3 
     | 
    
         
            -
                #  
     | 
| 
      
 3 
     | 
    
         
            +
                # Processor class for compilers and interpreters implemented in Java (or
         
     | 
| 
      
 4 
     | 
    
         
            +
                # on the JVM).
         
     | 
| 
       4 
5 
     | 
    
         
             
                #
         
     | 
| 
       5 
6 
     | 
    
         
             
                class Java
         
     | 
| 
       6 
     | 
    
         
            -
                  include CIAT::Processors::BasicProcessing
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                  # Traffic light
         
     | 
| 
       9 
7 
     | 
    
         
             
                  attr_accessor :kind
         
     | 
| 
       10 
8 
     | 
    
         
             
                  attr_accessor :description
         
     | 
| 
       11 
9 
     | 
    
         | 
| 
       12 
10 
     | 
    
         
             
                  # Creates a Java executor.
         
     | 
| 
       13 
     | 
    
         
            -
                  #
         
     | 
| 
       14 
     | 
    
         
            -
                  # Possible options:
         
     | 
| 
       15 
     | 
    
         
            -
                  # * <code>:description</code> is the description used in the HTML report 
         
     | 
| 
       16 
     | 
    
         
            -
                  #   for this processor (default: <code>"Parrot virtual machine"</code>).
         
     | 
| 
       17 
11 
     | 
    
         
             
                  def initialize(classpath, interpreter_class)
         
     | 
| 
       18 
12 
     | 
    
         
             
                    @classpath = classpath
         
     | 
| 
       19 
13 
     | 
    
         
             
                    @interpreter_class = interpreter_class
         
     | 
| 
         @@ -14,9 +14,6 @@ module CIAT 
     | 
|
| 
       14 
14 
     | 
    
         
             
                # is executed.
         
     | 
| 
       15 
15 
     | 
    
         
             
                # If none is provided, no command-line arguments are used.
         
     | 
| 
       16 
16 
     | 
    
         
             
                class Parrot
         
     | 
| 
       17 
     | 
    
         
            -
                  include CIAT::Processors::BasicProcessing
         
     | 
| 
       18 
     | 
    
         
            -
                  include CIAT::Differs::HtmlDiffer
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
17 
     | 
    
         
             
                  attr_accessor :kind
         
     | 
| 
       21 
18 
     | 
    
         
             
                  attr_accessor :description
         
     | 
| 
       22 
19 
     | 
    
         
             
                  attr_accessor :libraries
         
     | 
    
        data/lib/ciat/subresult.rb
    CHANGED
    
    | 
         @@ -1,11 +1,21 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class CIAT::Subresult
         
     | 
| 
       2 
2 
     | 
    
         
             
              attr_reader :light
         
     | 
| 
       3 
     | 
    
         
            -
              attr_reader : 
     | 
| 
      
 3 
     | 
    
         
            +
              attr_reader :path_kind
         
     | 
| 
      
 4 
     | 
    
         
            +
              attr_reader :subtest
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
              def initialize(elements, light,  
     | 
| 
      
 6 
     | 
    
         
            +
              def initialize(elements, path_kind, light, subtest)
         
     | 
| 
       6 
7 
     | 
    
         
             
                @elements = elements
         
     | 
| 
      
 8 
     | 
    
         
            +
                @path_kind = path_kind
         
     | 
| 
       7 
9 
     | 
    
         
             
                @light = light
         
     | 
| 
       8 
     | 
    
         
            -
                @ 
     | 
| 
      
 10 
     | 
    
         
            +
                @subtest = subtest
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
              
         
     | 
| 
      
 13 
     | 
    
         
            +
              def happy_path?
         
     | 
| 
      
 14 
     | 
    
         
            +
                path_kind == :happy
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
              
         
     | 
| 
      
 17 
     | 
    
         
            +
              def processor
         
     | 
| 
      
 18 
     | 
    
         
            +
                subtest.processor
         
     | 
| 
       9 
19 
     | 
    
         
             
              end
         
     | 
| 
       10 
20 
     | 
    
         | 
| 
       11 
21 
     | 
    
         
             
              def relevant_elements
         
     | 
| 
         @@ -15,6 +25,6 @@ class CIAT::Subresult 
     | 
|
| 
       15 
25 
     | 
    
         
             
              end
         
     | 
| 
       16 
26 
     | 
    
         | 
| 
       17 
27 
     | 
    
         
             
              def relevant_element_names
         
     | 
| 
       18 
     | 
    
         
            -
                 
     | 
| 
      
 28 
     | 
    
         
            +
                processor.kind.relevant_elements(@light, @subtest.path_kind)
         
     | 
| 
       19 
29 
     | 
    
         
             
              end
         
     | 
| 
       20 
30 
     | 
    
         
             
            end
         
     | 
    
        data/lib/ciat/subtest.rb
    ADDED
    
    | 
         @@ -0,0 +1,83 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rake'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'ciat/differs/html_differ'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class CIAT::Subtest
         
     | 
| 
      
 5 
     | 
    
         
            +
              include CIAT::Differs::HtmlDiffer
         
     | 
| 
      
 6 
     | 
    
         
            +
              
         
     | 
| 
      
 7 
     | 
    
         
            +
              attr_reader :processor
         
     | 
| 
      
 8 
     | 
    
         
            +
              
         
     | 
| 
      
 9 
     | 
    
         
            +
              def initialize(ciat_file, processor)
         
     | 
| 
      
 10 
     | 
    
         
            +
                @ciat_file = ciat_file
         
     | 
| 
      
 11 
     | 
    
         
            +
                @processor = processor
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
              def describe
         
     | 
| 
      
 15 
     | 
    
         
            +
                @processor.describe
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
              
         
     | 
| 
      
 18 
     | 
    
         
            +
              # Executes the program, and diffs the output.
         
     | 
| 
      
 19 
     | 
    
         
            +
              def process
         
     | 
| 
      
 20 
     | 
    
         
            +
                if execute
         
     | 
| 
      
 21 
     | 
    
         
            +
                  if diff
         
     | 
| 
      
 22 
     | 
    
         
            +
                    CIAT::TrafficLight::GREEN
         
     | 
| 
      
 23 
     | 
    
         
            +
                  else
         
     | 
| 
      
 24 
     | 
    
         
            +
                    CIAT::TrafficLight::RED
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
                else
         
     | 
| 
      
 27 
     | 
    
         
            +
                  CIAT::TrafficLight::YELLOW
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              def execute
         
     | 
| 
      
 32 
     | 
    
         
            +
                RakeFileUtils.verbose(false) do
         
     | 
| 
      
 33 
     | 
    
         
            +
                  sh(command_line) do |ok, result|
         
     | 
| 
      
 34 
     | 
    
         
            +
                    return happy_path? == ok
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
              
         
     | 
| 
      
 39 
     | 
    
         
            +
              def happy_path?
         
     | 
| 
      
 40 
     | 
    
         
            +
                @ciat_file.element?(@processor.kind.happy_path_element)
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
              
         
     | 
| 
      
 43 
     | 
    
         
            +
              def sad_path?
         
     | 
| 
      
 44 
     | 
    
         
            +
                not happy_path?
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
              
         
     | 
| 
      
 47 
     | 
    
         
            +
              def path_kind
         
     | 
| 
      
 48 
     | 
    
         
            +
                happy_path? ? :happy : :sad
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
              
         
     | 
| 
      
 51 
     | 
    
         
            +
              def command_line
         
     | 
| 
      
 52 
     | 
    
         
            +
                "#{@processor.executable} '#{input_file}' #{command_line_args} > '#{output_file}' 2> '#{error_file}'"
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
              
         
     | 
| 
      
 55 
     | 
    
         
            +
              def command_line_args
         
     | 
| 
      
 56 
     | 
    
         
            +
                if @ciat_file.element?(:command_line)
         
     | 
| 
      
 57 
     | 
    
         
            +
                  @ciat_file.element(:command_line).content.strip
         
     | 
| 
      
 58 
     | 
    
         
            +
                else
         
     | 
| 
      
 59 
     | 
    
         
            +
                  ''
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
              
         
     | 
| 
      
 63 
     | 
    
         
            +
              def input_file
         
     | 
| 
      
 64 
     | 
    
         
            +
                @ciat_file.element(@processor.kind.input_name).as_file
         
     | 
| 
      
 65 
     | 
    
         
            +
              end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
              def output_file
         
     | 
| 
      
 68 
     | 
    
         
            +
                @ciat_file.element(@processor.kind.output_name, :generated).as_file
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
              def error_file
         
     | 
| 
      
 72 
     | 
    
         
            +
                @ciat_file.element(@processor.kind.error_name, :generated).as_file
         
     | 
| 
      
 73 
     | 
    
         
            +
              end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
              # Compares the expected and generated executions.
         
     | 
| 
      
 76 
     | 
    
         
            +
              def diff
         
     | 
| 
      
 77 
     | 
    
         
            +
                element_name = happy_path? ? @processor.kind.output_name : @processor.kind.error_name
         
     | 
| 
      
 78 
     | 
    
         
            +
                html_diff(
         
     | 
| 
      
 79 
     | 
    
         
            +
                  @ciat_file.element(element_name).as_file,
         
     | 
| 
      
 80 
     | 
    
         
            +
                  @ciat_file.element(element_name, :generated).as_file, 
         
     | 
| 
      
 81 
     | 
    
         
            +
                  @ciat_file.element(element_name, :diff).as_file)
         
     | 
| 
      
 82 
     | 
    
         
            +
              end
         
     | 
| 
      
 83 
     | 
    
         
            +
            end
         
     |