Class: CIAT::Suite
- Inherits:
-
Object
- Object
- CIAT::Suite
- 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
.ciatin a folder namedciat, -
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:
-
:processorsis required and specifies the processors to be executed; order matters! -
:folderspecifies folders to search for test files (default:ciat/**). -
:patternspecifies a pattern for matching test files (default:*.ciat). -
:filesis an array of specific files (default: none). -
:output_folderis the output folder (default:temp) -
:report_filenameis the name of the report (default:report.htmlin the output folder) -
:feedbackspecifies 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
-
#cargo ⇒ Object
readonly
Returns the value of attribute cargo.
-
#processors ⇒ Object
readonly
Returns the value of attribute processors.
-
#report_title ⇒ Object
readonly
Returns the value of attribute report_title.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
- #create_test(crate) ⇒ Object
-
#initialize(options = {}) ⇒ Suite
constructor
Constructs a suite of CIAT tests.
-
#run ⇒ Object
Runs all of the tests in the suite, and returns the results.
-
#size ⇒ Object
Returns the number of tests in the suite.
-
#test_processors ⇒ Object
:nodoc:.
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( = {}) @processors = [:processors] @cargo = [:cargo] || CIAT::Cargo.new() @report_title = "CIAT Report" if [:report_title] @report_title = @report_title + ": " + [:report_title] end @feedback = [:feedback] || default_feedback @feedback = CIAT::Feedback::Composite.new( @feedback, CIAT::Feedback::ReturnStatus.new ) end |
Instance Attribute Details
#cargo ⇒ Object (readonly)
Returns the value of attribute cargo.
57 58 59 |
# File 'lib/ciat/suite.rb', line 57 def cargo @cargo end |
#processors ⇒ Object (readonly)
Returns the value of attribute processors.
59 60 61 |
# File 'lib/ciat/suite.rb', line 59 def processors @processors end |
#report_title ⇒ Object (readonly)
Returns the value of attribute report_title.
60 61 62 |
# File 'lib/ciat/suite.rb', line 60 def report_title @report_title end |
#results ⇒ Object (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 |
#run ⇒ Object
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 |
#size ⇒ Object
Returns the number of tests in the suite.
78 79 80 |
# File 'lib/ciat/suite.rb', line 78 def size cargo.size end |
#test_processors ⇒ Object
:nodoc:
100 101 102 |
# File 'lib/ciat/suite.rb', line 100 def test_processors #:nodoc: @processors.map { |processor| processor.for_test } end |