Skip to content

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Apr 30, 2024

This PR adds the --enable-code-coverage flag (from swift test) to swift build so that code coverage can be used in a two-stage build process (build, then execute later.)

Resolves rdar://127309781.
Resolves #7373.

This PR adds the `--enable-code-coverage` flag (from `swift test`) to `swift build` so that code coverage can be used in a two-stage build process (build, then execute later.)

Resolves rdar://127309781.
@grynspan grynspan added enhancement swift test Changes impacting `swift test` tool swift build Changes impacting `swift build` command-line interface labels Apr 30, 2024
@grynspan grynspan self-assigned this Apr 30, 2024
@grynspan grynspan requested a review from plemarquand April 30, 2024 21:09
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan grynspan enabled auto-merge (squash) April 30, 2024 21:18
@grynspan grynspan merged commit fe28c77 into main Apr 30, 2024
@grynspan grynspan deleted the jgrynspan/127309781-code-cov-build-flag branch April 30, 2024 23:48
plemarquand added a commit to plemarquand/vscode-swift that referenced this pull request May 1, 2024
Support running swift-testing tests the same as XCTests. If a test run
has both types, swift-testing tests will be run first followed by
XCTests.

First a list of XCTests and swift-testing tests to run is parsed from
the test request. Test type is determined by a tag on each
vscode.TestItem[], either `"XCTest"` or `"swift-testing"`.

swift-testing tests are launched by running the binary named
<PackageName>PackageTests.swift-testing inside the build debug folder.
This binary is run with the `--experimental-event-stream-output` flag
which forwards test events (test started, complete, issue recorded, etc)
to a named pipe. The `SwiftTestingOutputParser` watches this pipe for
events as the tests are being run and translates them in to
`ITestRunner` calls to record test progress in VSCode.

There are different named pipe reader implementations between
macOS/Linux and Windows.

TODO: Coverage on swift-testing tests is not supported until
swiftlang/swift-package-manager#7518 is available.
plemarquand added a commit to plemarquand/vscode-swift that referenced this pull request May 1, 2024
Support running swift-testing tests the same as XCTests. If a test run
has both types, swift-testing tests will be run first followed by
XCTests.

First a list of XCTests and swift-testing tests to run is parsed from
the test request. Test type is determined by a tag on each
`vscode.TestItem[]`, either `"XCTest"` or `"swift-testing"`.

swift-testing tests are launched by running the binary named
<PackageName>PackageTests.swift-testing inside the build debug folder.
This binary is run with the `--experimental-event-stream-output` flag
which forwards test events (test started, complete, issue recorded, etc)
to a named pipe. The `SwiftTestingOutputParser` watches this pipe for
events as the tests are being run and translates them in to
`ITestRunner` calls to record test progress in VSCode.

There are different named pipe reader implementations between
macOS/Linux and Windows.

TODO: Coverage on swift-testing tests is not supported until
swiftlang/swift-package-manager#7518 is available.
plemarquand added a commit to plemarquand/vscode-swift that referenced this pull request May 1, 2024
Support running swift-testing tests the same as XCTests. If a test run
has both types, swift-testing tests will be run first followed by
XCTests.

First a list of XCTests and swift-testing tests to run is parsed from
the test request. Test type is determined by a tag on each
`vscode.TestItem[]`, either `"XCTest"` or `"swift-testing"`.

swift-testing tests are launched by running the binary named
<PackageName>PackageTests.swift-testing inside the build debug folder.
This binary is run with the `--experimental-event-stream-output` flag
which forwards test events (test started, complete, issue recorded, etc)
to a named pipe. The `SwiftTestingOutputParser` watches this pipe for
events as the tests are being run and translates them in to
`ITestRunner` calls to record test progress in VSCode.

There are different named pipe reader implementations between
macOS/Linux and Windows.

TODO: Coverage on swift-testing tests is not supported until
swiftlang/swift-package-manager#7518 is available.
plemarquand added a commit to plemarquand/vscode-swift that referenced this pull request May 12, 2024
Support running swift-testing tests the same as XCTests. If a test run
has both types, swift-testing tests will be run first followed by
XCTests.

First a list of XCTests and swift-testing tests to run is parsed from
the test request. Test type is determined by a tag on each
`vscode.TestItem[]`, either `"XCTest"` or `"swift-testing"`.

swift-testing tests are launched by running the binary named
<PackageName>PackageTests.swift-testing inside the build debug folder.
This binary is run with the `--experimental-event-stream-output` flag
which forwards test events (test started, complete, issue recorded, etc)
to a named pipe. The `SwiftTestingOutputParser` watches this pipe for
events as the tests are being run and translates them in to
`ITestRunner` calls to record test progress in VSCode.

There are different named pipe reader implementations between
macOS/Linux and Windows.

TODO: Coverage on swift-testing tests is not supported until
swiftlang/swift-package-manager#7518 is available.
furby-tm pushed a commit to wabiverse/swift-package-manager that referenced this pull request May 15, 2024
This PR adds the `--enable-code-coverage` flag (from `swift test`) to
`swift build` so that code coverage can be used in a two-stage build
process (build, then execute later.)

Resolves rdar://127309781.
grynspan added a commit that referenced this pull request May 15, 2024
This PR adds the `--enable-code-coverage` flag (from `swift test`) to
`swift build` so that code coverage can be used in a two-stage build
process (build, then execute later.)

Resolves rdar://127309781.
grynspan added a commit that referenced this pull request May 15, 2024
Explanation: Add `--enable-code-coverage` to `swift build`. This flag
allows enabling code coverage when splitting a test run between `swift
build` and `swift test --skip-build`.
Scope: New option for the `swift build` command.
Original PR: #7508 (partial), #7518
Risk: Low. Behaviour is identical for `swift build` without the new
flag, and the new flag must be explicitly specified.
Testing: Ran `swift build` unit tests at desk and in CI.
Reviewer: @bnbarham, @MaxDesiatov, @stmontgomery

---------

Co-authored-by: Max Desiatov <m_desiatov@apple.com>
furby-tm pushed a commit to wabiverse/swift-package-manager that referenced this pull request May 15, 2024
This PR adds the `--enable-code-coverage` flag (from `swift test`) to
`swift build` so that code coverage can be used in a two-stage build
process (build, then execute later.)

Resolves rdar://127309781.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command-line interface enhancement swift build Changes impacting `swift build` swift test Changes impacting `swift test` tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No way to just-build with code coverage enabled.
2 participants