Skip to content

Commit

Permalink
Fix duplicate use_system_scm option in #17832 (#17957)
Browse files Browse the repository at this point in the history
* Bump rspec version

This will allow usage of `include("foo").once`

* Add failing test

      1) Scan Scan::TestCommandGenerator uses system scm options exactly once
         Failure/Error: expect(result).to include("-scmProvider system").once

           expected ["set -o pipefail &&", "env NSUnbufferedIO=YES xcodebuild", "-scheme app", "-project ./scan/examples/...it --output '/var/folders/qz/91qlx7gn30l6rfcwjfzsv_ph0000gn/T/junit_report20210113-97481-17c5v9n' "] to include "-scmProvider system" once but it is included twice

* Deduplicate scmProvider option

* Fix build command generator

* Remove extra blank line
  • Loading branch information
plu committed Jan 14, 2021
1 parent 6c3c9a9 commit febf68a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fastlane.gemspec
Expand Up @@ -102,7 +102,7 @@ Gem::Specification.new do |spec|

# Development only
spec.add_development_dependency('rake')
spec.add_development_dependency('rspec', '~> 3.9.0')
spec.add_development_dependency('rspec', '~> 3.10.0')
spec.add_development_dependency('rspec_junit_formatter', '~> 0.4.1')
spec.add_development_dependency('pry')
spec.add_development_dependency('pry-byebug')
Expand Down
4 changes: 3 additions & 1 deletion gym/lib/gym/generators/build_command_generator.rb
Expand Up @@ -39,7 +39,9 @@ def options
options << "-destination '#{config[:destination]}'" if config[:destination]
options << "-archivePath #{archive_path.shellescape}" unless config[:skip_archive]
options << "-resultBundlePath '#{result_bundle_path}'" if config[:result_bundle]
options << "-scmProvider system" if config[:use_system_scm]
if config[:use_system_scm] && !options.include?("-scmProvider system")
options << "-scmProvider system"
end
options << config[:xcargs] if config[:xcargs]
options << "OTHER_SWIFT_FLAGS=\"-Xfrontend -debug-time-function-bodies\"" if config[:analyze_build_time]

Expand Down
19 changes: 18 additions & 1 deletion gym/spec/build_command_generator_spec.rb
Expand Up @@ -6,6 +6,7 @@
end

before(:each) do
@project.options.values.delete(:use_system_scm)
allow(Gym).to receive(:project).and_return(@project)
end

Expand Down Expand Up @@ -92,7 +93,23 @@
options = { project: "./gym/examples/standard/Example.xcodeproj", use_system_scm: true }
Gym.config = FastlaneCore::Configuration.create(Gym::Options.available_options, options)
result = Gym::BuildCommandGenerator.generate
expect(result).to include("-scmProvider system")
expect(result).to include("-scmProvider system").once
end

it "uses system scm via project options", requires_xcodebuild: true do
options = { project: "./gym/examples/standard/Example.xcodeproj" }
@project.options[:use_system_scm] = true
Gym.config = FastlaneCore::Configuration.create(Gym::Options.available_options, options)
result = Gym::BuildCommandGenerator.generate
expect(result).to include("-scmProvider system").once
end

it "uses system scm options exactly once", requires_xcodebuild: true do
options = { project: "./gym/examples/standard/Example.xcodeproj", use_system_scm: true }
@project.options[:use_system_scm] = true
Gym.config = FastlaneCore::Configuration.create(Gym::Options.available_options, options)
result = Gym::BuildCommandGenerator.generate
expect(result).to include("-scmProvider system").once
end

it "defaults to Xcode scm when option is not provided", requires_xcodebuild: true do
Expand Down
4 changes: 3 additions & 1 deletion scan/lib/scan/test_command_generator.rb
Expand Up @@ -32,13 +32,15 @@ def options # rubocop:disable Metrics/PerceivedComplexity

options = []
options += project_path_array unless config[:xctestrun]
options << "-scmProvider system" if config[:use_system_scm]
options << "-sdk '#{config[:sdk]}'" if config[:sdk]
options << destination # generated in `detect_values`
options << "-toolchain '#{config[:toolchain]}'" if config[:toolchain]
if config[:derived_data_path] && !options.include?("-derivedDataPath #{config[:derived_data_path].shellescape}")
options << "-derivedDataPath #{config[:derived_data_path].shellescape}"
end
if config[:use_system_scm] && !options.include?("-scmProvider system")
options << "-scmProvider system"
end
options << "-resultBundlePath '#{result_bundle_path}'" if config[:result_bundle]
if FastlaneCore::Helper.xcode_at_least?(10)
options << "-parallel-testing-worker-count #{config[:concurrent_workers]}" if config[:concurrent_workers]
Expand Down
19 changes: 18 additions & 1 deletion scan/spec/test_command_generator_spec.rb
Expand Up @@ -76,6 +76,7 @@
describe Scan::TestCommandGenerator do
before(:each) do
@test_command_generator = Scan::TestCommandGenerator.new
@project.options.values.delete(:use_system_scm)
end

it "raises an exception when project path wasn't found" do
Expand Down Expand Up @@ -163,7 +164,23 @@
options = { project: "./scan/examples/standard/app.xcodeproj", use_system_scm: true }
Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)
result = @test_command_generator.generate
expect(result).to include("-scmProvider system")
expect(result).to include("-scmProvider system").once
end

it "uses system scm via project options", requires_xcodebuild: true do
options = { project: "./scan/examples/standard/app.xcodeproj" }
@project.options[:use_system_scm] = true
Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)
result = @test_command_generator.generate
expect(result).to include("-scmProvider system").once
end

it "uses system scm options exactly once", requires_xcodebuild: true do
options = { project: "./scan/examples/standard/app.xcodeproj", use_system_scm: true }
@project.options[:use_system_scm] = true
Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)
result = @test_command_generator.generate
expect(result).to include("-scmProvider system").once
end

it "defaults to Xcode scm when option is not provided", requires_xcodebuild: true do
Expand Down

0 comments on commit febf68a

Please sign in to comment.