[SR-7446] Code coverage generation using the Swift 4.1 toolchain doesn't reach conditional code paths in init methods #49989
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
code coverage
Area → source tooling: code coverage
compiler
The Swift compiler in itself
regression
swift 4.1
Attachment: Download
Environment
Version 9.3 (9E145)
Swift 4.1
Additional Detail from JIRA
md5: db109c5ce197c124399547fb2436272a
Issue Description:
Since upgrading to Xcode 9.3/Swift 4.1, I noticed that code coverage percentage dropped in several of my projects.
The bug seems to occur when I use conditional code within an initializer:
Neither the if/else branches nor the switch cases are counted towards line coverage when compiling with Xcode 9.3 and "Gather coverage" turned on.
I wrote test cases (see attached project "Codepath.zip") that exercise the code paths in question and verified their execution with the debugger.
Older Xcode versions or the swift-4.0.3-RELEASE-osx toolchain from swift.org report correct percentages when I enable code coverage in the Test phase of the scheme.
I also tested the behaviour with a command line tool (see attached project "codepath-cli.zip") and
When using Xcode 9.3's default toolchain, conditional code within the initializer is not reached. When using the 4.0.3 final toolchain, all conditional code is counted correctly (at least once).
The test CLI tool project contains xcrun-based scripts to generate & show coverage for the Xcode default toolchain (showCoverageSwift41.sh) and the final 4.0.3 toolchain (showCoverageSwift403).
The text was updated successfully, but these errors were encountered: