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

swift build --build-tests doesn't work with --enable-test-discovery flag #7389

Closed
MaxDesiatov opened this issue Mar 4, 2024 · 10 comments · Fixed by #7391 or #7396
Closed

swift build --build-tests doesn't work with --enable-test-discovery flag #7389

MaxDesiatov opened this issue Mar 4, 2024 · 10 comments · Fixed by #7391 or #7396
Assignees
Labels
bug needs tests This change needs test coverage swift build Changes impacting `swift build`

Comments

@MaxDesiatov
Copy link
Member

It appears the lack of tests hurt us here: this pull broke swift build --build-tests registering the --enable-test-discovery flag also. My Android CI builds swift-numerics trunk daily with the latest Swift trunk snapshot builds and those flags: it now errors with the March 1 snapshot.

I can reproduce the crash on linux x86_64 with the following commands, which work with the last Feb. 29 trunk snapshot before this pull:

> ../swift-DEVELOPMENT-SNAPSHOT-2024-03-01-a-ubi9/usr/bin/swift build --build-tests --enable-test-discovery
> .build/x86_64-unknown-linux-gnu/debug/swift-numericsPackageTests.xctest

Originally posted by @finagolfin in #7377 (comment)

@MaxDesiatov MaxDesiatov added bug swift test Changes impacting `swift test` tool labels Mar 4, 2024
@MaxDesiatov MaxDesiatov added the needs tests This change needs test coverage label Mar 4, 2024
@grynspan
Copy link
Contributor

grynspan commented Mar 4, 2024

--enable-test-discovery is deprecated and has no effect anymore; it will be removed in a future update. We should move this over to swift-numerics to remove the LinuxMain.swift file. I'm guessing WindowsMain.swift can be updated too.

@MaxDesiatov I don't seem to be able to move the issue over myself (presumably a permissions issue.)

@grynspan grynspan assigned MaxDesiatov and unassigned grynspan Mar 4, 2024
@MaxDesiatov
Copy link
Member Author

I can't move that either. Created apple/swift-numerics#280 in the meantime.

@MaxDesiatov MaxDesiatov closed this as not planned Won't fix, can't repro, duplicate, stale Mar 4, 2024
@grynspan
Copy link
Contributor

grynspan commented Mar 4, 2024

Reopening while I make sure that --enable-test-discovery doesn't outright break the build. It'll either end up being a one-line fix or a complete removal of the option (save for a vestigial deprecation warning.)

@grynspan grynspan reopened this Mar 4, 2024
@grynspan grynspan assigned grynspan and unassigned MaxDesiatov Mar 4, 2024
@grynspan grynspan added swift build Changes impacting `swift build` and removed swift test Changes impacting `swift test` tool labels Mar 4, 2024
@MaxDesiatov
Copy link
Member Author

With #7391 under review, I don't think this issue should stay open.

@grynspan
Copy link
Contributor

grynspan commented Mar 4, 2024

Sure thing. I didn't realize you'd opened that PR! We can forward-dup this issue to that PR then.

@grynspan
Copy link
Contributor

grynspan commented Mar 4, 2024

Duplicate of #7391

@grynspan grynspan marked this as a duplicate of #7391 Mar 4, 2024
@grynspan grynspan closed this as not planned Won't fix, can't repro, duplicate, stale Mar 4, 2024
@finagolfin
Copy link
Contributor

--enable-test-discovery is deprecated and has no effect anymore

The very fact disabling the flag in your pull broke running a package's tests shows it had an effect prior to your pull.

I don't think removing the --enable-test-discovery flag yet is a good idea, eg the most recent 1.2.1 tag of swift-system from a couple years ago has a LinuxMain.swift and so does the most recent 1.0.2 tag of swift-numerics, so you will no longer be able to test those tags with a trunk toolchain if you remove this flag.

There should be a push in the Swift community to remove those files first, particularly in Apple's own repos like these, before you can remove the flag. @tomerd?

@MaxDesiatov
Copy link
Member Author

so you will no longer be able to test those tags with a trunk toolchain if you remove this flag.

You won't be able to tests those packages with swift test --enable-test-discovery, but you can still test them with plain swift test.

@finagolfin
Copy link
Contributor

You won't be able to tests those packages with swift test --enable-test-discovery, but you can still test them with plain swift test.

How so? While that flag is currently unnecessary generally, it is still useful to override older tags of packages that still have a LinuxMain.swift, like the two I just linked. Unless you start ignoring those old files too, this flag is still needed to resolve the ambiguity of whether to use those manual files or not.

MaxDesiatov added a commit that referenced this issue Mar 5, 2024
This flag was deprecated for 4 years since Swift 5.4, Swift 6.0 is a good opportunity to remove it.

Closes #7389.
@bnbarham
Copy link
Contributor

bnbarham commented Mar 5, 2024

Reverting this in #7395 as it's blocking our PR testing.

We also seem to be using LinuxMain.swift here, as @finagolfin noted in #7394 (comment) (we check for XCTMain.swift and LinuxMain.swift). This will of course then cause the original issue that @finagolfin originally opened.

As far as I understand, it seems the intention of the --enable-test-discovery deprecation was to also deprecate the entry point files, ie. the tests are automatically discovered on all platforms meant "you don't need --enable-test-discovery or the entry-point files". It's not clear to me whether this was/is clear enough to users though.

I'd say we have a couple of choices here:

  1. Remove this flag but also remove the default entry point handling
  2. Fix the original issue without removing the flag, @grynspan sounded like he had a fix in mind for that above

As an aside, is --enable-experimental-test-entry-point also broken after #7377?

grynspan added a commit that referenced this issue Mar 6, 2024
…7396)

Ensures that a fully-initialized `TestingParameters` structure is used
with `swift build --build-tests` instead of using any default parameters
(which will tend us toward the wrong output with packages that use
`--enable-test-discovery` and still have LinuxMain.swift files.)

Tested with swift-numerics on Ubuntu 22.04 aarch64; before the change,
we'd hit the `fatalError()` call in that package's LinuxMain.swift file.
After the change, we correctly run XCTest-based tests.

Resolves #7389.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs tests This change needs test coverage swift build Changes impacting `swift build`
Projects
None yet
4 participants