Class: TestFiles
Overview
The collection of Test Files.
Constant Summary collapse
- TEST_FILE_PATTERN =
'**/*.test.gloo'
Instance Method Summary collapse
-
#add(file) ⇒ Object
Add a test file to the collection.
-
#count ⇒ Object
Get the number of test files.
-
#detect_files ⇒ Object
Detect test files.
-
#each(&block) ⇒ Object
Iterator method for Enumerable interface.
-
#initialize(engine, input_files = nil) ⇒ TestFiles
constructor
Set up the test file.
-
#look_for_files_in(dir) ⇒ Object
Look for test files in a directory.
-
#randomize ⇒ Object
Randomize the order of the test files.
-
#use_input_files ⇒ Object
Use the files and or directories specified by the user.
Constructor Details
#initialize(engine, input_files = nil) ⇒ TestFiles
Set up the test file.
12 13 14 15 16 |
# File 'lib/test_files.rb', line 12 def initialize( engine, input_files = nil ) @engine = engine @input_files = input_files @files = [] end |
Instance Method Details
#add(file) ⇒ Object
Add a test file to the collection.
73 74 75 |
# File 'lib/test_files.rb', line 73 def add( file ) @files << TestFile.new( @engine, file ) end |
#count ⇒ Object
Get the number of test files.
88 89 90 |
# File 'lib/test_files.rb', line 88 def count return @files.length end |
#detect_files ⇒ Object
Detect test files.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/test_files.rb', line 21 def detect_files @engine.log.debug "Detecting test files…" if @input_files.length > 0 use_input_files else # Use the current directory look_for_files_in Dir.pwd end @engine.log.debug "Found #{count} test files" end |
#each(&block) ⇒ Object
Iterator method for Enumerable interface.
95 96 97 |
# File 'lib/test_files.rb', line 95 def each(&block) @files.each(&block) end |
#look_for_files_in(dir) ⇒ Object
Look for test files in a directory. The directory might be provided as a parameter to the test runner, or if no parameter is provided, it is the current directory.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/test_files.rb', line 59 def look_for_files_in dir @engine.log.debug "Looking for test files in: #{dir}" root = File.join( dir, TEST_FILE_PATTERN ) files = Dir.glob( root ) @engine.log.debug "Found files: #{@files}" files.each do |f| @engine.log.debug "Found: #{f}" add f end end |
#randomize ⇒ Object
Randomize the order of the test files.
80 81 82 83 |
# File 'lib/test_files.rb', line 80 def randomize @engine.log.debug "Randomizing test files…" @files.shuffle! end |
#use_input_files ⇒ Object
Use the files and or directories specified by the user.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/test_files.rb', line 37 def use_input_files @engine.log.debug "Input files specified: #{@input_files}" @input_files.each do |f| @engine.log.debug "Test file specified: #{f}" if Dir.exist?( f ) # Expand path for file f = File.( f ) look_for_files_in f elsif File.exist?( f ) add( f ) else # TODO: Show error puts "Test file does not exist: #{f}" end end end |