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

[SR-16057] Include target name in Linux test output. #343

Open
adam-fowler opened this issue Mar 24, 2022 · 5 comments
Open

[SR-16057] Include target name in Linux test output. #343

adam-fowler opened this issue Mar 24, 2022 · 5 comments

Comments

@adam-fowler
Copy link

Previous ID SR-16057
Radar None
Original Reporter @adam-fowler
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s XCTest
Labels Improvement
Assignee None
Priority Medium

md5: 796a6b7c95c2f0761a5fa1880bf3d0bf

Issue Description:

When you run `swift test` on macOS it includes the target name in the output of each test.

Test Case '-[BasicsTests.AuthorizationProviderTests testBasicAPIs]' started.
Test Case '-[BasicsTests.AuthorizationProviderTests testBasicAPIs]' passed (0.001 seconds).

When you run the same on Linux it doesn't include the target name

Test Case 'AuthorizationProviderTests.testBasicAPIs' started at 2022-03-24 17:20:00.
Test Case 'AuthorizationProviderTests.testBasicAPIs' passed (0.001 seconds).

If you are parsing the output from the Linux version this makes it harder to work out what actual test passed/failed especially if your Package.swift has two targets which both have a test suite and function name with the same name.

Would it be possible to update the output to include the target name.

The context for this is I am parsing the output of `swift test` to update the status of Tests in the Test Explorer in the Swift Visual Studio Code Extension.

@tomerd
Copy link
Member

tomerd commented Mar 24, 2022

cc @stmontgomery

@tomerd
Copy link
Member

tomerd commented Mar 24, 2022

@swift-ci

@stmontgomery
Copy link
Contributor

When using XCTest on macOS, whether or not the module name (which is usually the same as the test target name) is included in this kind of log depends on whether the name of the test class has the module as part of its name. On Apple platforms, which have the ObjC runtime, `XCTestCase` subclasses are themselves `@objc` and so by default, without any customization, their formal class names have their module name as a prefix. E.g. `<ModuleName>.<ClassName>`.

But it is possible to customize the ObjC name on Apple platforms, e.g. `@objc(ClassName) class ClassName: XCTestCase {}`, in which case the textual log would not include the module name prefix on the class name. In other words, the textual log simply prints whatever the formal class name is, and it's not always guaranteed to have the module name prefix.

On non-Apple platforms, `XCTestCase` is not `@objc` and so there is never a prefix. So hopefully that gives some background about the discrepancy which can arise here.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
@tomerd
Copy link
Member

tomerd commented Sep 15, 2023

@neonichu can the new output handler help here?

@neonichu
Copy link
Member

I don't believe so, we can just pass along what we get as names for test cases from XCTest callbacks. I am assuming those values will be identical to what is being printed to the console.

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

No branches or pull requests

4 participants