SlatherOrg / slather

Generate test coverage reports for Xcode projects & hook it into CI.
MIT License
1.56k stars 237 forks source link

Again "No product binary found" #252

Open eimantas opened 8 years ago

eimantas commented 8 years ago

I'm using sonar-swift plugin. It utilises slather to run tests, however I keep getting the error when running following command:

slather coverage --input-format profdata -i .*Tests.*% --cobertura-xml --output-directory sonar-reports --scheme Project Project.xcodeproj

The error:

/Library/Ruby/Gems/2.0.0/gems/slather-2.3.0/lib/slather/project.rb:459:in `find_binary_files': No product binary found in /Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/Project-doaardmvqfnnqpbxqmpeejvisrqq/Build/Intermediates/CodeCoverage. (StandardError)
    from /Library/Ruby/Gems/2.0.0/gems/slather-2.3.0/lib/slather/project.rb:344:in `configure_binary_file'
    from /Library/Ruby/Gems/2.0.0/gems/slather-2.3.0/lib/slather/project.rb:240:in `configure'
    from /Library/Ruby/Gems/2.0.0/gems/slather-2.3.0/lib/slather/command/coverage_command.rb:51:in `execute'
    from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/command.rb:67:in `run'
    from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb:11:in `execute'
    from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/command.rb:67:in `run'
    from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/command.rb:132:in `run'
    from /Library/Ruby/Gems/2.0.0/gems/slather-2.3.0/bin/slather:17:in `<top (required)>'
    from /usr/local/bin/slather:23:in `load'
    from /usr/local/bin/slather:23:in `<main>'

There are previous issues that I browsed through, but none of them apply to this situation:

The slather is run from jenkins.

szymont commented 7 years ago

@eimantas Were you able to find any workaround for the problem? I have a similar issue in my project using Xcode 8 and Slather 2.3.0

nsomar commented 7 years ago

Same issue here, it keeps printing the same :(

ramki982 commented 7 years ago

Same issue for me, With XCode 8 and slather 2.3.0 - I'm getting the exact issue. I do find the Coverage.profdata files in the derived data folder.

szymont commented 7 years ago

@ramki982 @oarrabi please try to set binary_basename key in slather action

ramki982 commented 7 years ago

@szymont - Thanks for the suggestion. Let me try that

MaikoHermans commented 7 years ago

@ramki982 Did you get it to work? I'm having the exact same problem

ramki982 commented 7 years ago

@MaikoHermans - yes it worked slather coverage --input-format profdata --binary-basename '<Name of my app>' --verbose --scheme <Name of test target> --workspace <relative path to workspace> <relative path to .xcodeproj>

One point to note is that input format, binary basename, scheme, workspace, verbose are all options to coverage and last argument is the path to project file. when @szymont suggested using binary basename, i appended it to the end of command & kept getting "Too many arguments" error.

jehyounglee commented 7 years ago

The issue has changed. I had same issue even adding binary-basename as @szymont suggested. In my case, the issue happens whenever Xcode test and slather are executed by a build agent in a remote build machine through VSTS. After performing Test (not Run) in Xcode manually on the build machine, the issue has gone. However, the code coverage reports always 0%. It doesn't collect the information properly.

cliren commented 7 years ago

I am still experiencing this issue with Xcode 8.1, Slather 2.3, ruby 2.1.5,

The tests are run before running slater and I see MyProjectForIos/Build/Intermediates/CodeCoverage/Coverage.profdata ` $ slather coverage --html --input-format profdata --binary-basename MyProjectDebug --verbose --workspace MyProject.xcworkspace --scheme MyProjectDebug MyProject.xcodeproj

Slathering... No product binary found in /Users/user1/MyProjectForIos/Build/Intermediates/CodeCoverage.

Are you sure your project is generating coverage? Make sure you enable code coverage in the Test section of your Xcode scheme.
Did you specify your Xcode scheme? (--scheme or 'scheme' in .slather.yml)
If you're using a workspace, did you specify it? (--workspace or 'workspace' in .slather.yml)

/Users/user1/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/slather-2.3.0/lib/slather/project.rb:459:in find_binary_files': No product binary found in /Users/user1/MyProjectForIos/Build/Intermediates/CodeCoverage. (StandardError)

jblack10101 commented 7 years ago

I was also having this issue using the sonar swift plugin, but I fixed it by adding a binary_basename value to my .slather.yml file. Just be sure you're using the correct name. It looks for the product binary in .app, .xctest, .framework, and .dylib files under the /Users//Library/Developer/Xcode/DerivedData//Build/Intermediates/CodeCoverage directory.

Yahsaswi commented 7 years ago

@jehyounglee I'm also facing the same issue. I go to the build machine directly and run tests and then run slather everything works. However, when I run it on Jenkins server it fails. Could you please mention if there is any working solution for the same, because going and running in the machine is a solution. Adding binary_basename in .slather.yml has not fixed the issue for me.

at-daonguyen commented 7 years ago

In my case, I ran tests with Release configuration. Just back to Debug or run slather coverage with --configuration Release.

aleksey-hariton-epam commented 6 years ago

In my case root case was here - https://github.com/SlatherOrg/slather/blob/8f6c4518244c415c6a00793341f5ae9aa9638f35/lib/slather/project.rb#L437

path.end_with?(".dSYM") || path.end_with?(".swiftmodule")

Mb someone will create patch? :)

kenji21 commented 6 years ago

not in a release yet, but current head https://github.com/SlatherOrg/slather/commit/69b74115aa3e0166230332e548d81aaeb669c973 (2.4.5 + 8 commit) fixes this issue for one of my projects