2018-04-05 10:06:01 +00:00
#!/usr/bin/env ruby
2021-02-12 12:09:02 +00:00
# frozen_string_literal: true
2018-04-05 10:06:01 +00:00
2021-02-23 09:10:45 +00:00
# tooling/rspec_flaky/flaky_examples_collection.rb is requiring
2018-04-11 13:51:31 +00:00
# `active_support/hash_with_indifferent_access`, and we install the `activesupport`
# gem manually on the CI
require 'rubygems'
2021-02-23 09:10:45 +00:00
require_relative '../../tooling/rspec_flaky/report'
2018-04-05 10:06:01 +00:00
report_file = ARGV.shift
unless report_file
puts 'usage: prune-old-flaky-specs <report-file> <new-report-file>'
exit 1
end
new_report_file = ARGV.shift || report_file
2018-04-10 11:22:38 +00:00
report = RspecFlaky::Report.load(report_file)
2018-04-05 10:06:01 +00:00
puts "Loading #{report_file}..."
2018-04-10 11:22:38 +00:00
puts "Current report has #{report.size} entries."
2018-04-05 10:06:01 +00:00
2018-04-10 11:22:38 +00:00
new_report = report.prune_outdated
2018-04-05 10:06:01 +00:00
2020-01-21 21:08:54 +00:00
puts "New report has #{new_report.size} entries: #{report.size - new_report.size} entries older than #{RspecFlaky::Report::OUTDATED_DAYS_THRESHOLD} days were removed."
2018-04-10 11:22:38 +00:00
puts "Saved #{new_report_file}." if new_report.write(new_report_file)