swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.71k stars 1.33k forks source link

[SR-12008] SwiftPM: On Linux, enable-test-discovery stumbles over deprecated tests #4628

Closed weissi closed 1 month ago

weissi commented 4 years ago
Previous ID SR-12008
Radar rdar://problem/58475855
Original Reporter @weissi
Type Bug
Status In Progress
Resolution
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 2 | |Component/s | Package Manager | |Labels | Bug, Linux | |Assignee | 3a4oT (JIRA) | |Priority | Medium | md5: fc60a1ed0f31111134228b7e176436d5

Issue Description:

It's very important to also test deprecated functionality which on Darwin is easily possible by deprecating the test method. When manually generating LinuxMain and friends, this is also possible via a small hack.

Repro:

git clone https://github.com/apple/swift-nio
cd swift-nio
docker run -it --rm -v "$PWD:$PWD" -w "$PWD" swift:5.1.3 swift test -Xswiftc -warnings-as-errors --enable-test-discovery

Expected:

Runs the tests just fine like on Darwin or without enable-test-discovery

Actual:

many errors.

/Users/johannes/devel/swift-nio/.build/x86_64-unknown-linux/debug/testlist.derived/NIOConcurrencyHelpersTests.swift:6:24: error: 'testAddSub()' is deprecated: deprecated because it tests deprecated functionality
        ("testAddSub", testAddSub),
                       ^
/Users/johannes/devel/swift-nio/.build/x86_64-unknown-linux/debug/testlist.derived/NIOConcurrencyHelpersTests.swift:8:35: error: 'testAllOperationsBool()' is deprecated: deprecated because it tests deprecated functionality
        ("testAllOperationsBool", testAllOperationsBool),
                                  ^
weissi commented 4 years ago

@swift-ci create

weissi commented 4 years ago

CC @aciidb0mb3r, can we adapt the generation so that it allows deprecated tests? They're really important.

aciidgh commented 4 years ago

I guess the hack used by NIO is our best option unless @briancroom has better ideas.

swift-ci commented 4 years ago

Comment by Petro Rovenskyy (JIRA)

@aciidb0mb3r, Based on PR feedback there was a suggestion to focus on compiler feature that allows disabling warning in sections of the code. My understanding it's something similar to what we have for Objective-C preprocessor)

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// actual code causing the deprecated warning
#pragma clang diagnostic pop

Is this assumption correct? Unfortunately, I do not have experience with the development of swiftc, and it would be awesome if you can clarify some possible action here.

In case such a feature will be implemented where the changes should go, to swiftPM's generated code (as was proposed on a first PR revision) or leave this option to the end-users(disable warnings in consumers code)?

Thanks in advance! cc @weissi

aciidgh commented 4 years ago

> Should I file a JIRA enhancement request or there is existing one we can link?

You can try doing a quick search on JIRA and file a new one if you can't find something.

> Is it possible to get some "pointers" in what direction to move and where to start with implementing such a feature?

I think this would first require going through the swift-evolution process in order to figure out what the right feature looks like. You can find out about the evolution process here: https://github.com/apple/swift-evolution

grynspan commented 1 month ago

Duplicate of #3992