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-11968] SwiftPM test discovery: creating extra tests in separate files causes build errors #4633

Closed
weissi opened this issue Dec 19, 2019 · 3 comments

Comments

@weissi
Copy link
Member

weissi commented Dec 19, 2019

Previous ID SR-11968
Radar rdar://problem/58438124
Original Reporter @weissi
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug, Linux
Assignee None
Priority Medium

md5: ef57b4e8fd91ce5cf7ed79d55aa6b477

duplicates:

  • SR-11951 Test discovery on Linux breaks with test class extensions in multiple files

Issue Description:

If in SwiftPM 5.1 on Linux you use --enable-test-discovery and have unit test cases for one test suite spread across multiple files (using extension SomeTests), you will see the following build errors:

$ docker run -it --rm -v "$PWD:$PWD" -w "$PWD" swift:5.1.3 swift test --enable-test-discovery
/tmp/repro/.build/x86_64-unknown-linux/debug/testlist.derived/reproTests.swift:11:16: error: invalid redeclaration of '__allTests__reproTests'
    static let __allTests__reproTests = [
               ^
/tmp/repro/.build/x86_64-unknown-linux/debug/testlist.derived/reproTests.swift:5:16: note: '__allTests__reproTests' previously declared here
    static let __allTests__reproTests = [
               ^
[10/12] Compiling reproPackageTests main.swift

The attached repository contains an easy repro.

$ tree Tests/
Tests/
├── LinuxMain.swift
└── reproTests
    ├── otherFile.swift
    └── reproTests.swift

with

$ cat Tests/reproTests/reproTests.swift 
import XCTest
@testable import repro

final class reproTests: XCTestCase {
    func testExample() {
        // This is an example of a functional test case.
        // Use XCTAssert and related functions to verify your tests produce the correct
        // results.
        XCTAssertEqual(repro().text, "Hello, World!")
    }
}

$ cat Tests/reproTests/otherFile.swift 
import Foundation

extension reproTests {
    func testSomthingInOtherFile() {
        
    }
}
@weissi
Copy link
Member Author

weissi commented Dec 19, 2019

CC @aciidb0mb3r/@neonichu

@weissi
Copy link
Member Author

weissi commented Dec 19, 2019

@swift-ci create

@ankitspd
Copy link
Member

This looks like a dupe of SR-11951

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
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

2 participants