Class: CIAT::Suite

Inherits:
Object
  • Object
show all
Defined in:
lib/ciat/suite.rb

Overview

A Suite of Tests

This is the top-level class for organizing CIAT tests. It can be used in a Rakefile like so:

task :ciat do
  CIAT::Suite.new(:processors => [compiler, executor]).run
end

You may find the CIAT::RakeTask a little bit easier and more familiar to use.

Specifying Test and Output Files and Folders

By default, this suite will do the following:

  • find tests ending in .ciat in a folder named ciat,

  • use simple standard-output feedback,

  • put all output files into a folder named temp,

  • produce an HTML report in temp/report.html.

Each of these settings can be overridden with these options:

  • :processors is required and specifies the processors to be executed; order matters!

  • :folder specifies folders to search for test files (default: ciat/**).

  • :pattern specifies a pattern for matching test files (default: *.ciat).

  • :files is an array of specific files (default: none).

  • :output_folder is the output folder (default: temp)

  • :report_filename is the name of the report (default: report.html in the output folder)

  • :feedback specifies a feedback mechanism (default: a CIAT::Feedback::StandardOutput).

:folder and :pattern can be used together; :files overrides both :folder and :pattern.

Processors

You can create your own processors. Each processor needs to specify which test elements it wants or will accept, which files it wants checked, and how it should be executed. See CIAT::Compilers::Java and CIAT::Executors::Parrot (to learn how to use them and how to write others).

Test File

See the README for details on the format of a test file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Suite

Constructs a suite of CIAT tests. See the instructions above for possible values for the options.



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/ciat/suite.rb', line 64

def initialize(options = {})
  @processors = options[:processors]
  @cargo = options[:cargo] || CIAT::Cargo.new(options)
  @report_title = "CIAT Report"
  if options[:report_title]
    @report_title = @report_title + ": " + options[:report_title]
  end
  @feedback = options[:feedback] || default_feedback
  @feedback = CIAT::Feedback::Composite.new(
      @feedback, CIAT::Feedback::ReturnStatus.new
    )
end

Instance Attribute Details

#cargoObject (readonly)

Returns the value of attribute cargo.



57
58
59
# File 'lib/ciat/suite.rb', line 57

def cargo
  @cargo
end

#processorsObject (readonly)

Returns the value of attribute processors.



59
60
61
# File 'lib/ciat/suite.rb', line 59

def processors
  @processors
end

#report_titleObject (readonly)

Returns the value of attribute report_title.



60
61
62
# File 'lib/ciat/suite.rb', line 60

def report_title
  @report_title
end

#resultsObject (readonly)

Returns the value of attribute results.



58
59
60
# File 'lib/ciat/suite.rb', line 58

def results
  @results
end

Instance Method Details

#create_test(crate) ⇒ Object



93
94
95
96
97
98
# File 'lib/ciat/suite.rb', line 93

def create_test(crate)
  CIAT::Test.new(crate.test_file,
    crate.process_test_file,
    :processors => test_processors,
    :feedback => @feedback)
end

#runObject

Runs all of the tests in the suite, and returns the results. The results are also available through #results.



84
85
86
87
88
89
90
91
# File 'lib/ciat/suite.rb', line 84

def run
  @feedback.pre_tests(self)
  @results = cargo.crates.
    map { |crate| create_test(crate) }.
    map { |test| test.run }
  @feedback.post_tests(self)
  @results
end

#sizeObject

Returns the number of tests in the suite.



78
79
80
# File 'lib/ciat/suite.rb', line 78

def size
  cargo.size
end

#test_processorsObject

:nodoc:



100
101
102
# File 'lib/ciat/suite.rb', line 100

def test_processors #:nodoc:
  @processors.map { |processor| processor.for_test }
end