Class: Fastlane::Actions::SuppressedTestsAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/retry_tests/actions/suppressed_tests.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



63
64
65
# File 'lib/fastlane/plugin/retry_tests/actions/suppressed_tests.rb', line 63

def self.authors
  ["lyndsey-ferguson/@lyndseydf"]
end

.available_optionsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fastlane/plugin/retry_tests/actions/suppressed_tests.rb', line 40

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :xcodeproj,
      env_name: "FL_SUPPRESSED_TESTS_XCODE_PROJECT",
      description: "The file path to the Xcode project file to read the skipped tests from",
      verify_block: proc do |path|
        UI.user_error!("Error: Xcode project file path not given!") unless path and !path.empty?
        UI.user_error!("Error: Xcode project '#{path}' not found!") unless Dir.exist?(path)
      end
    ),
    FastlaneCore::ConfigItem.new(
      key: :scheme,
      optional: true,
      env_name: "FL_SUPPRESSED_TESTS_SCHEME_TO_UPDATE",
      description: "The Xcode scheme where the suppressed tests may be",
      verify_block: proc do |scheme_name|
        UI.user_error!("Error: Xcode Scheme '#{scheme_name}' is not valid!") if scheme_name and scheme_name.empty?
      end
    )
  ]
end

.descriptionObject



36
37
38
# File 'lib/fastlane/plugin/retry_tests/actions/suppressed_tests.rb', line 36

def self.description
  "Retrieves a list of tests that are suppressed in a specific or all Xcode Schemes in a project"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/fastlane/plugin/retry_tests/actions/suppressed_tests.rb', line 67

def self.is_supported?(platform)
  platform == :ios
end

.run(params) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fastlane/plugin/retry_tests/actions/suppressed_tests.rb', line 6

def self.run(params)
  project_path = params[:xcodeproj]
  scheme = params[:scheme]

  scheme_filepaths = Dir.glob("#{project_path}/{xcshareddata,xcuserdata}/**/xcschemes/#{scheme || '*'}.xcscheme")
  if scheme_filepaths.length.zero?
    UI.user_error!("Error: cannot find any scheme named #{scheme}") unless scheme.nil?
    UI.user_error!("Error: cannot find any schemes in the Xcode project")
  end

  skipped_tests = Set.new
  scheme_filepaths.each do |scheme_filepath|
    xcscheme = Xcodeproj::XCScheme.new(scheme_filepath)
    xcscheme.test_action.testables.each do |testable|
      buildable_name = testable.buildable_references[0]
                               .buildable_name

      buildable_name = File.basename(buildable_name, '.xctest')
      testable.skipped_tests.map do |skipped_test|
        skipped_tests.add("#{buildable_name}/#{skipped_test.identifier}")
      end
    end
  end
  skipped_tests.to_a
end