Commit bcb7a995 authored by Rémy Coutable's avatar Rémy Coutable

Use RspecFlaky::Report in scripts/prune-old-flaky-specs

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent b11e8875
#!/usr/bin/env ruby
require 'bundler/setup'
Bundler.require(:default)
require_relative '../lib/rspec_flaky/flaky_examples_collection'
require_relative '../lib/rspec_flaky/examples_pruner'
require_relative '../lib/rspec_flaky/report'
report_file = ARGV.shift
unless report_file
......@@ -13,21 +9,11 @@ unless report_file
end
new_report_file = ARGV.shift || report_file
DAYS_THRESHOLD = 90
def days_from_now(days)
Time.now - (3600 * 24 * days)
end
report = RspecFlaky::Report.load(report_file)
puts "Loading #{report_file}..."
collection = RspecFlaky::FlakyExamplesCollection.new(JSON.parse(File.read(report_file)))
puts "Current report has #{collection.size} entries."
new_collection = RspecFlaky::ExamplesPruner.new(collection).prune_examples_older_than(days_from_now(DAYS_THRESHOLD))
puts "Current report has #{report.size} entries."
puts "New report has #{new_collection.size} entries: #{collection.size - new_collection.size} entries older than #{DAYS_THRESHOLD} days were removed."
new_report = report.prune_outdated
File.write(new_report_file, JSON.pretty_generate(new_collection.to_report))
puts "Saved #{new_report_file}."
puts "New report has #{new_report.size} entries: #{report.size - new_report.size} entries older than 90 days were removed."
puts "Saved #{new_report_file}." if new_report.write(new_report_file)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment