Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't crash if a source file doesn't exist #492

Merged
merged 1 commit into from
Apr 25, 2021
Merged

Don't crash if a source file doesn't exist #492

merged 1 commit into from
Apr 25, 2021

Conversation

chillpop
Copy link
Contributor

In our CI setup, we're running into a crash in slather when trying to process a profdata file:

Errno::ENOENT: No such file or directory @ rb_check_realpath_internal - /{path on build machine}/DerivedData/Build/Intermediates.noindex/{redacted}.build/Debug-iphonesimulator/{redacted}.build/DerivedSources/resource_bundle_accessor.swift

{omitted for clarity}/gems/slather-2.6.1/lib/slather/project.rb:138:in realpath
{omitted for clarity}/gems/slather-2.6.1/lib/slather/project.rb:138:in block (2 levels) in pathnames_per_binary
{omitted for clarity}/gems/slather-2.6.1/lib/slather/project.rb:137:in map
{omitted for clarity}/gems/slather-2.6.1/lib/slather/project.rb:137:in block in pathnames_per_binary
{omitted for clarity}/gems/slather-2.6.1/lib/slather/project.rb:136:in each
{omitted for clarity}/gems/slather-2.6.1/lib/slather/project.rb:136:in reduce
{omitted for clarity}/gems/slather-2.6.1/lib/slather/project.rb:136:in pathnames_per_binary
{omitted for clarity}/gems/slather-2.6.1/lib/slather/project.rb:124:in block in profdata_coverage_files
{omitted for clarity}/gems/slather-2.6.1/lib/slather/project.rb:123:in each
{omitted for clarity}/gems/slather-2.6.1/lib/slather/project.rb:123:in profdata_coverage_files
{omitted for clarity}/gems/slather-2.6.1/lib/slather/project.rb:98:in coverage_files
{omitted for clarity}/gems/slather-2.6.1/lib/slather/coverage_service/cobertura_xml_output.rb:18:in post
{omitted for clarity}/gems/slather-2.6.1/lib/slather/command/coverage_command.rb:101:in post
{omitted for clarity}/gems/slather-2.6.1/lib/slather/command/coverage_command.rb:61:in execute
{omitted for clarity}/gems/clamp-1.3.2/lib/clamp/command.rb:66:in run
{omitted for clarity}/gems/clamp-1.3.2/lib/clamp/subcommand/execution.rb:18:in execute
{omitted for clarity}/gems/clamp-1.3.2/lib/clamp/command.rb:66:in run
{omitted for clarity}/gems/clamp-1.3.2/lib/clamp/command.rb:140:in run
{omitted for clarity}/gems/slather-2.6.1/bin/slather:17:in <top (required)>

The file that does not exist is autogenerated by Xcode for a Swift Package with a resource bundle. It cannot be found due to a complex CI setup where one machine compiles code for testing and a different machine runs the tests.

This failure happens when first parsing the coverage data and before we get a chance to ignore that file. I'd like to be able to get past the parsing step without crashing for missing files.

To resolve this, I'm checking to see if the filename from the coverage file exists on disk before calling realpath. If not, the path in the coverage file is used as is.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.005%) to 96.226% when pulling 9e73270 on chillpop:check-exists-for-realpath into 6fa3d4c on SlatherOrg:master.

@ksuther
Copy link
Contributor

ksuther commented Apr 25, 2021

Thanks for the PR!

@ksuther ksuther merged commit 91a8b29 into SlatherOrg:master Apr 25, 2021
@chillpop
Copy link
Contributor Author

Thanks for the merge @ksuther.
Do you know when you will be including this in a new Slather release?

@ksuther
Copy link
Contributor

ksuther commented Apr 30, 2021

I'll try to do one in the next few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants