Skip to content

[scan] Fix build_for_testing failure to fail - #29718

Open
alvarhansen wants to merge 1 commit into
fastlane:masterfrom
alvar-bolt:alvar/scan/fix-build-for-testing-failure
Open

[scan] Fix build_for_testing failure to fail#29718
alvarhansen wants to merge 1 commit into
fastlane:masterfrom
alvar-bolt:alvar/scan/fix-build-for-testing-failure

Conversation

@alvarhansen

@alvarhansen alvarhansen commented Oct 15, 2025

Copy link
Copy Markdown
Contributor

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I see several green ci/circleci builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.
  • I've added or updated relevant unit tests.

Motivation and Context

Resolves #20685

Description

scan's ErrorHandler.handle_build_error has explicit logic that checks for /Executed/ pattern in logs. It seems to be meant for case where tests will be run with same command and so we would want to wait for test results parsing instead. But this is causing scan to not to fail under build_for_testing configuration when there is such pattern in logs (eg. some file name contains it).

In order to fix this, I propose to explicitly check for exit status code in build_for_testing mode and produce an error if status is not ok.

Testing Steps

  • Have file in the project with a name that contains "Executed".
  • Have compile error in the test building.
  • Run scan with build_for_testing: true
  • fastlane succeeds

Example project https://github.com/alvar-bolt/fastlane-scan-failure-poc

@iBotPeaches iBotPeaches left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for delay on this. CI is failing and we've moved away from CircleCI. So if you rebase/merge-master and take a look at the failures. We can revisit.

Scan's `ErrorHandler.handle_build_error` has explicit logic that
checks for `/Executed/` pattern in logs. It seems to be meant for case
where tests will be run with same command and so we would want to wait
for test results parsing instead. But this is causing scan to not to
fail under `build_for_testing` configuration when there is such
pattern in logs (eg. some file name contains it).

In order to fix this, I propose to explicitly check for exit status
code in `build_for_testing` mode and produce an error if status is not
ok.

Fixes fastlane#20685
@alvarhansen
alvarhansen force-pushed the alvar/scan/fix-build-for-testing-failure branch from 6d587ff to 18078bf Compare August 16, 2026 07:38
@alvarhansen

Copy link
Copy Markdown
Contributor Author

@iBotPeaches i've rebased my PR and all checks are now green.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a scan regression where build_for_testing: true could incorrectly succeed when xcodebuild fails but the build log contains the word Executed (e.g., in a filename), by ensuring the xcodebuild exit status is honored in build_for_testing mode.

Changes:

  • Update Scan::Runner#handle_results to raise a build failure on any non-zero xcodebuild exit status when build_for_testing is enabled.
  • Add a regression spec that reproduces the “Executed in output prevents failure” scenario and asserts a FastlaneBuildFailure is raised.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
scan/spec/runner_spec.rb Adds regression coverage for the build_for_testing + “Executed” output scenario.
scan/lib/scan/runner.rb Ensures build_for_testing runs fail on non-zero xcodebuild exit status.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scan/spec/runner_spec.rb
Comment on lines +196 to +200
allow(FastlaneCore::CommandExecutor).to receive(:execute) do |command:, print_all:, print_command:, prefix:, loading:, suppress_output:, error:|
system("ruby -e 'exit 65'")
error.call(error_output)
""
end
Comment thread scan/spec/runner_spec.rb
end

describe "when :build_for_testing is true" do
it "fails the run if xcodebuild exits with a non-zero status even when error output contains 'Executed'", requires_xcodebuild: true do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fastlane reports succes when xcodebuild fails

4 participants