2021-12-03 03:14:42 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# This script assumes the first argument is a path to a file containing a list of changed files and the second argument
|
|
|
|
# is the path of a file where a list of end-to-end spec files with the leading 'qa/' trimmed will be written to if
|
|
|
|
# all the files are end-to-end test spec files.
|
|
|
|
|
|
|
|
abort("ERROR: Please specify the file containing the list of changed files and a file where the qa only spec files will be written") if ARGV.size != 2
|
|
|
|
|
2021-12-06 18:14:09 +00:00
|
|
|
changed_files_path = ARGV.shift
|
2021-12-03 03:14:42 +00:00
|
|
|
output_file = ARGV.shift
|
|
|
|
|
2021-12-06 18:14:09 +00:00
|
|
|
return unless File.exist?(changed_files_path)
|
|
|
|
|
|
|
|
changed_files = File.read(changed_files_path).split(' ')
|
|
|
|
|
|
|
|
all_files_are_qa_specs = changed_files.all? { |file_path| file_path =~ %r{^qa\/qa\/specs\/features\/} }
|
|
|
|
|
2021-12-03 03:14:42 +00:00
|
|
|
if all_files_are_qa_specs
|
2021-12-06 18:14:09 +00:00
|
|
|
qa_spec_paths_trimmed = changed_files.map { |path| path.sub('qa/', '') }
|
2021-12-03 03:14:42 +00:00
|
|
|
File.write(output_file, qa_spec_paths_trimmed.join(' '))
|
|
|
|
end
|