support for my new super-fast way of running failed tests, one-at-a-time rerun.txt-like mode
This commit is contained in:
parent
86c4d08dc3
commit
b9a04a0052
|
@ -0,0 +1,39 @@
|
||||||
|
module CukePack
|
||||||
|
class Profiles
|
||||||
|
def self.write
|
||||||
|
std_opts = "-r features --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} -f Cucumber::StepWriter --out features/step_definitions --strict"
|
||||||
|
|
||||||
|
in_progress_file = 'in_progress.txt'
|
||||||
|
rerun_file = 'rerun.txt'
|
||||||
|
|
||||||
|
in_progress = nil
|
||||||
|
if File.file?(in_progress_file)
|
||||||
|
in_progress = File.readlines(in_progress_file).first
|
||||||
|
|
||||||
|
if in_progress
|
||||||
|
in_progress = nil if in_progress.empty?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if in_progress
|
||||||
|
File.open(rerun_file, 'wb') { |fh| fh.print in_progress }
|
||||||
|
|
||||||
|
wip_opts = %{RERUN_FILE=#{rerun_file} RUN_INPROGRESS=#{in_progress_file} #{std_opts} @#{rerun_file}}
|
||||||
|
else
|
||||||
|
wip_opts = %{#{std_opts} --tags @wip features}
|
||||||
|
end
|
||||||
|
|
||||||
|
headless_driver = ENV['DRIVER'] || 'poltergeist'
|
||||||
|
|
||||||
|
headless_opts = %{DRIVER=#{headless_driver} INPROGRESS=#{in_progress_file} #{std_opts}}
|
||||||
|
|
||||||
|
<<-YML
|
||||||
|
default: #{headless_opts} features
|
||||||
|
wip: #{wip_opts}
|
||||||
|
precommit: #{headless_opts} --tags ~@wip:0 features
|
||||||
|
cleanup: #{headless_opts} -f Cucumber::CleanupFormatter --out unused.txt features
|
||||||
|
YML
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
# after tests fail, re-run only failed scenarios, but one at a time so as not to oeverwhelm
|
||||||
|
|
||||||
|
in_progress = []
|
||||||
|
any_failed = false
|
||||||
|
|
||||||
|
if ENV['INPROGRESS']
|
||||||
|
File.unlink(ENV['INPROGRESS']) if File.file?(ENV['INPROGRESS'])
|
||||||
|
end
|
||||||
|
|
||||||
|
After do |s|
|
||||||
|
if s.failed?
|
||||||
|
if ENV['INPROGRESS']
|
||||||
|
in_progress << s.feature.file_colon_line(s.line)
|
||||||
|
end
|
||||||
|
|
||||||
|
if ENV['RUN_INPROGRESS']
|
||||||
|
any_failed = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
at_exit do
|
||||||
|
include Cucumber::Term::ANSIColor
|
||||||
|
|
||||||
|
if ENV['INPROGRESS'] and !in_progress.empty?
|
||||||
|
File.open(ENV['INPROGRESS'], 'wb') { |fh| fh.print in_progress.join("\n") }
|
||||||
|
|
||||||
|
puts red("*** Failing scenarios described in #{ENV['INPROGRESS']}. Run using the wip profile until they're fixed. ***")
|
||||||
|
end
|
||||||
|
|
||||||
|
if ENV['RUN_INPROGRESS']
|
||||||
|
if !any_failed
|
||||||
|
lines = File.readlines(ENV['RUN_INPROGRESS'])
|
||||||
|
passed = lines.shift
|
||||||
|
|
||||||
|
if lines.empty?
|
||||||
|
File.unlink(ENV['RUN_INPROGRESS'])
|
||||||
|
File.unlink(ENV['RERUN_FILE'])
|
||||||
|
|
||||||
|
puts green("*** You're done! All failed features have passed. ***")
|
||||||
|
else
|
||||||
|
File.open(ENV['RUN_INPROGRESS'], 'wb') { |fh| fh.print lines.join('') }
|
||||||
|
|
||||||
|
puts yellow("*** Still working - #{lines.length} feature#{lines.length == 1 ? '' : 's'} to go! ***")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue