Module: Pork::Shuffled

Included in:
Executor
Defined in:
lib/pork/mode/shuffled.rb

Instance Method Summary collapse

Instance Method Details

#[](source_location) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/pork/mode/shuffled.rb', line 14

def [] source_location
  file_str, line_str = source_location.split(':')
  file, line = File.expand_path(file_str), line_str.to_i
  return unless tests = all_tests[file]
  _, paths = tests.reverse_each.find{ |(l, _)| l <= line }
  paths
end

#all_pathsObject



10
11
12
# File 'lib/pork/mode/shuffled.rb', line 10

def all_paths
  all_tests.values.flat_map(&:values).flatten(1)
end

#all_testsObject



6
7
8
# File 'lib/pork/mode/shuffled.rb', line 6

def all_tests
  @all_tests ||= build_all_tests
end

#shuffled(stat = Stat.new, paths = all_paths) ⇒ Object



22
23
24
# File 'lib/pork/mode/shuffled.rb', line 22

def shuffled stat=Stat.new, paths=all_paths
  paths.shuffle.inject(stat, &method(:isolate))
end