Skip to content

Listing tests with empty LinuxMain.swift outputs error message (Swift 5.8) #5744

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

Closed
adam-fowler opened this issue Aug 23, 2022 · 17 comments
Closed
Labels
bug swift test Changes impacting `swift test` tool

Comments

@adam-fowler
Copy link

adam-fowler commented Aug 23, 2022

Description

Running swift test list outputs an error for SwiftPM packages that have an empty LinuxMain.swift

Expected behavior

swift test list to output a list of all the tests in a package

Actual behavior

It outputs

error: malformed

Steps to reproduce

  1. swift package init
  2. touch Tests/LinuxMain.swift
  3. swift test list

Swift Package Manager version/commit hash

No response

Swift & OS version (output of swift --version && uname -a)

Swift version 5.8-dev (LLVM f6b60d5b8f4b443, Swift ecccce61139bbc4)
Target: x86_64-unknown-linux-gnu
Linux af-starbook 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

@tomerd
Copy link
Contributor

tomerd commented Jan 11, 2023

@adam-fowler is this still an issue?

❯ swift test --list-tests
[1/1] Planning buildCompiling plugin Swift-DocC...
Compiling plugin Swift-DocC Preview...
Building for debugging...
Build complete! (0.78s)
MQTTNIOTests.AsyncMQTTNIOTests/testAsyncSequencePublishListener
MQTTNIOTests.AsyncMQTTNIOTests/testAsyncSequencePublishSubscriptionIdListener
MQTTNIOTests.AsyncMQTTNIOTests/testConnect
MQTTNIOTests.AsyncMQTTNIOTests/testPing
MQTTNIOTests.AsyncMQTTNIOTests/testPublishSubscribe
MQTTNIOTests.CoreMQTTTests/testConnect
MQTTNIOTests.CoreMQTTTests/testPublish
MQTTNIOTests.CoreMQTTTests/testSubscribe
MQTTNIOTests.MQTTNIOTests/testCloseListener
MQTTNIOTests.MQTTNIOTests/testConnectWithUsernameAndPassword
MQTTNIOTests.MQTTNIOTests/testConnectWithWill
MQTTNIOTests.MQTTNIOTests/testConnectWithWrongUsernameAndPassword
MQTTNIOTests.MQTTNIOTests/testDoubleConnect
MQTTNIOTests.MQTTNIOTests/testDoubleShutdown
MQTTNIOTests.MQTTNIOTests/testInflight
MQTTNIOTests.MQTTNIOTests/testListenerReferenceCycle
MQTTNIOTests.MQTTNIOTests/testMQTTPingreq
MQTTNIOTests.MQTTNIOTests/testMQTTPublishQoS0
MQTTNIOTests.MQTTNIOTests/testMQTTPublishQoS1
MQTTNIOTests.MQTTNIOTests/testMQTTPublishQoS2
MQTTNIOTests.MQTTNIOTests/testMQTTPublishRetain
MQTTNIOTests.MQTTNIOTests/testMQTTPublishToClient
MQTTNIOTests.MQTTNIOTests/testMQTTPublishToClientLargePayload
MQTTNIOTests.MQTTNIOTests/testMQTTServerClose
MQTTNIOTests.MQTTNIOTests/testMQTTSubscribe
MQTTNIOTests.MQTTNIOTests/testMultipleTasks
MQTTNIOTests.MQTTNIOTests/testPacketId
MQTTNIOTests.MQTTNIOTests/testPersistentSession
MQTTNIOTests.MQTTNIOTests/testPing
MQTTNIOTests.MQTTNIOTests/testRawIPConnect
MQTTNIOTests.MQTTNIOTests/testSessionPresent
MQTTNIOTests.MQTTNIOTests/testSSLConnect
MQTTNIOTests.MQTTNIOTests/testSSLConnectFromP12
MQTTNIOTests.MQTTNIOTests/testSubscribeAll
MQTTNIOTests.MQTTNIOTests/testUnsubscribe
MQTTNIOTests.MQTTNIOTests/testWebsocketAndSSLConnect
MQTTNIOTests.MQTTNIOTests/testWebsocketConnect
MQTTNIOTests.MQTTNIOv5Tests/testAuth
MQTTNIOTests.MQTTNIOv5Tests/testBadAuthenticationMethod
MQTTNIOTests.MQTTNIOv5Tests/testBadPublish
MQTTNIOTests.MQTTNIOv5Tests/testConnect
MQTTNIOTests.MQTTNIOv5Tests/testConnectWithBinaryDataProperty
MQTTNIOTests.MQTTNIOv5Tests/testConnectWithNoIdentifier
MQTTNIOTests.MQTTNIOv5Tests/testConnectWithStringPairProperty
MQTTNIOTests.MQTTNIOv5Tests/testConnectWithUInt16Property
MQTTNIOTests.MQTTNIOv5Tests/testConnectWithUInt32Property
MQTTNIOTests.MQTTNIOv5Tests/testConnectWithUInt8Property
MQTTNIOTests.MQTTNIOv5Tests/testConnectWithWill
MQTTNIOTests.MQTTNIOv5Tests/testInvalidTopicName
MQTTNIOTests.MQTTNIOv5Tests/testMQTTContentType
MQTTNIOTests.MQTTNIOv5Tests/testMQTTSubscribe
MQTTNIOTests.MQTTNIOv5Tests/testMQTTSubscribeFlags
MQTTNIOTests.MQTTNIOv5Tests/testOutOfRangeTopicAlias
MQTTNIOTests.MQTTNIOv5Tests/testPersistentSession
MQTTNIOTests.MQTTNIOv5Tests/testPublishQoS1
MQTTNIOTests.MQTTNIOv5Tests/testPublishQoS1WithProperty
MQTTNIOTests.MQTTNIOv5Tests/testPublishQoS2
MQTTNIOTests.MQTTNIOv5Tests/testPublishWithSubscription
MQTTNIOTests.MQTTNIOv5Tests/testSessionPresent
MQTTNIOTests.MQTTNIOv5Tests/testSubscribeAll
MQTTNIOTests.MQTTNIOv5Tests/testUnsubscribe
MQTTNIOTests.MQTTNIOv5Tests/testUserProperty

@adam-fowler
Copy link
Author

Going to close this just now as I cannot replicate it.

@adam-fowler
Copy link
Author

adam-fowler commented Jan 14, 2023

Re-opening, just managed to replicate this.

@adam-fowler
Copy link
Author

It looks like it is related to packages that have a LinuxMain.swift

@MaxDesiatov
Copy link
Contributor

MaxDesiatov commented Jan 14, 2023

Assuming we don't support LinuxMain.swift anymore IIRC, do we need a separate issue or to reopen this one to track that the error message itself should be fixed?

@adam-fowler
Copy link
Author

A 5.8 release of swift should not have breaking changes in it though. Projects that built and test fine with swift 5.7 should do so with 5.8 as well.

@MaxDesiatov
Copy link
Contributor

Right, so reopening this one seems more suitable then?

@adam-fowler
Copy link
Author

I closed this issue then within 5 minutes realised it was still an issue so reopened it and managed to narrow down what the problem was.

@MaxDesiatov
Copy link
Contributor

Ah, ok. I was a bit confused since the status for me is still showing up as closed.

@MaxDesiatov MaxDesiatov reopened this Jan 14, 2023
@adam-fowler
Copy link
Author

Ah, ok. I was a bit confused since the status for me is still showing up as closed.

Ha I'm an idiot, forgot to re-open it

@adam-fowler
Copy link
Author

I've also worked out the LinuxMain.swift needs to empty for the issue to occur. See https://forums.swift.org/t/test-discovery-on-linux/26203/10 for reasons why you might have an empty LinuxMain.swift

@adam-fowler adam-fowler changed the title Listing tests outputs error message (Swift 5.8) Listing tests outputs error message (Swift 5.8) with empty LinuxMain.swift Jan 14, 2023
@adam-fowler adam-fowler changed the title Listing tests outputs error message (Swift 5.8) with empty LinuxMain.swift Listing tests with empty LinuxMain.swift outputs error message (Swift 5.8) Jan 14, 2023
@finagolfin
Copy link
Member

@adam-fowler, some diagnostics for this error were just merged in trunk, #6860, try it with the next trunk snapshot build- the current Aug. 25 snapshot doesn't have that commit- and see if it helps.

@adam-fowler
Copy link
Author

I now get

error: invalid list test JSON structure, produced by /home/adamfowler/Developer/server/mqtt-nio/.build/x86_64-unknown-linux-gnu/debug/mqtt-nioPackageTests.xctest --dump-tests-json, underlying error: malformed(json: "", underlyingError: Error Domain=NSCocoaErrorDomain Code=3840 "The data is not in the correct format.")

@neonichu
Copy link
Contributor

neonichu commented Sep 5, 2023

Thanks for the update, sounds like an empty JSON is produced?

@mapedd
Copy link

mapedd commented Mar 20, 2024

@adam-fowler any luck working around this?

@adam-fowler
Copy link
Author

@mapedd I haven't seen this in a long time. Although I've removed LinuxMain.swift from pretty much all of my projects.

@grynspan
Copy link
Contributor

Closing per Adam's latest comment; if somebody's still running into this issue, please do reopen!

@grynspan grynspan closed this as not planned Won't fix, can't repro, duplicate, stale Aug 13, 2024
@grynspan grynspan added the swift test Changes impacting `swift test` tool label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug swift test Changes impacting `swift test` tool
Projects
None yet
Development

No branches or pull requests

7 participants