diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-20 15:15:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-20 15:15:52 +0300 |
commit | fa10e47f6e1dced92a7b28dee7fab08abeead777 (patch) | |
tree | 67d4d292b548fd0007b9c7d0bdc86e47954d634b /tooling | |
parent | b762fdffd054da31601d4e9f8dbd35ff9d198b59 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'tooling')
-rwxr-xr-x | tooling/bin/find_tests | 18 | ||||
-rw-r--r-- | tooling/lib/tooling/find_tests.rb | 33 | ||||
-rw-r--r-- | tooling/lib/tooling/mappings/view_to_js_mappings.rb | 2 |
3 files changed, 38 insertions, 15 deletions
diff --git a/tooling/bin/find_tests b/tooling/bin/find_tests index 33834064f36..31afa4d598b 100755 --- a/tooling/bin/find_tests +++ b/tooling/bin/find_tests @@ -1,19 +1,9 @@ #!/usr/bin/env ruby # frozen_string_literal: true -require 'test_file_finder' +require_relative '../lib/tooling/find_tests' -changes = ARGV.shift -output_file = ARGV.shift +changes_file = ARGV.shift +matching_tests_paths = ARGV.shift -changed_files = File.read(changes).split(' ') - -tff = TestFileFinder::FileFinder.new(paths: changed_files).tap do |file_finder| - file_finder.use TestFileFinder::MappingStrategies::PatternMatching.load('tests.yml') - - if ENV['RSPEC_TESTS_MAPPING_ENABLED'] - file_finder.use TestFileFinder::MappingStrategies::DirectMatching.load_json(ENV['RSPEC_TESTS_MAPPING_PATH']) - end -end - -File.write(output_file, tff.test_files.uniq.join(' ')) +Tooling::FindTests.new(changes_file, matching_tests_paths).execute diff --git a/tooling/lib/tooling/find_tests.rb b/tooling/lib/tooling/find_tests.rb new file mode 100644 index 00000000000..4acbb5fcd6a --- /dev/null +++ b/tooling/lib/tooling/find_tests.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'test_file_finder' + +module Tooling + class FindTests + def initialize(changes_file, matching_tests_paths) + @matching_tests_paths = matching_tests_paths + @changed_files = File.read(changes_file).split(' ') + + File.write(matching_tests_paths, '') unless File.exist?(matching_tests_paths) + + @matching_tests = File.read(matching_tests_paths).split(' ') + end + + def execute + tff = TestFileFinder::FileFinder.new(paths: changed_files).tap do |file_finder| + file_finder.use TestFileFinder::MappingStrategies::PatternMatching.load('tests.yml') + + if ENV['RSPEC_TESTS_MAPPING_ENABLED'] == 'true' + file_finder.use TestFileFinder::MappingStrategies::DirectMatching.load_json(ENV['RSPEC_TESTS_MAPPING_PATH']) + end + end + + new_matching_tests = tff.test_files.uniq + File.write(matching_tests_paths, (matching_tests + new_matching_tests).join(' ')) + end + + private + + attr_reader :changed_files, :matching_tests, :matching_tests_paths + end +end diff --git a/tooling/lib/tooling/mappings/view_to_js_mappings.rb b/tooling/lib/tooling/mappings/view_to_js_mappings.rb index db80eb9bfe8..bf305d6738d 100644 --- a/tooling/lib/tooling/mappings/view_to_js_mappings.rb +++ b/tooling/lib/tooling/mappings/view_to_js_mappings.rb @@ -11,7 +11,7 @@ module Tooling HTML_ATTRIBUTE_VALUE_REGEXP = /js-[-\w]+/.freeze # Search for Rails partials included in an HTML file - RAILS_PARTIAL_INVOCATION_REGEXP = %r{(?:render|render_if_exist)(?: |\()(?:partial: ?)?['"]([\w/-]+)['"]}.freeze + RAILS_PARTIAL_INVOCATION_REGEXP = %r{(?:render|render_if_exists)(?: |\()(?:partial: ?)?['"]([\w/-]+)['"]}.freeze def initialize(view_base_folder: 'app/views', js_base_folder: 'app/assets/javascripts') @view_base_folders = folders_for_available_editions(view_base_folder) |