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

Allow attributes after #[timeout] #28

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

Darksonn
Copy link
Contributor

@Darksonn Darksonn commented Jun 6, 2024

Closes: #27
Closes: tokio-rs/tokio#6610

@Darksonn
Copy link
Contributor Author

Darksonn commented Jun 6, 2024

Ah, I guess this only fixes the issue with #[timeout]. If there are also cases where #[test_case] doesn't work, then that would be separate.

@Darksonn
Copy link
Contributor Author

Darksonn commented Jun 6, 2024

Actually, looks like it has never worked with #[test_case]. Using the old version of Tokio, we get:

#[tokio::test]
#[test_case(10)]
async fn timeout(arg: i32) {
    assert!(arg != 12);
}
error: functions used as tests can not have any arguments
  --> src/main.rs:9:7
   |
9  |   async fn timeout(arg: i32) {
   |  _______^
10 | |     assert!(arg != 12);
11 | | }
   | |_^

and

#[test_case(10)]
#[tokio::test]
async fn timeout(arg: i32) {
    assert!(arg != 12);
}
error: custom attribute panicked
 --> src/main.rs:7:1
  |
7 | #[test_case(10)]
  | ^^^^^^^^^^^^^^^^
  |
  = help: message: Expected identifier!

@Darksonn
Copy link
Contributor Author

Darksonn commented Jun 6, 2024

@zeenix You said that this used to work for you. Can you give a working example with #[test_case]?

@zeenix
Copy link

zeenix commented Jun 6, 2024

@zeenix You said that this used to work for you. Can you give a working example with #[test_case]?

Sure, the failing pipeline I pointed to, was of the (unmerged) PR that upgrades tokio. All other jobs have been passing. You can also just checkout busd and run cargo t in the main branch, if you want to reproduce locally (it should work on Linux, Windows and MacOs).

@Darksonn
Copy link
Contributor Author

Darksonn commented Jun 6, 2024

I cloned the repository you linked and searched for the string "test_case", but there are no results. I can only find uses of #[timeout], not #[test_case].

@zeenix
Copy link

zeenix commented Jun 6, 2024

I cloned the repository you linked and searched for the string "test_case", but there are no results. I can only find uses of #[timeout], not #[test_case].

Oh test_case. No, I actually don't think I've ever used that. My bug was only about timeout.

@Darksonn
Copy link
Contributor Author

Darksonn commented Jun 6, 2024

Are you able to verify that this PR fixes your issue?

See: https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html

@zeenix
Copy link

zeenix commented Jun 7, 2024

Are you able to verify that this PR fixes your issue?

I am happy to report that it does. :)

❯ cargo t
    Updating git repository `ssh://github.com/Darksonn/ntest.git`
   Compiling ntest_test_cases v0.9.2 (ssh://github.com/Darksonn/ntest.git?branch=alice/fix-attrs-after-timeout#f8d523e0)
   Compiling ntest_timeout v0.9.2 (ssh://github.com/Darksonn/ntest.git?branch=alice/fix-attrs-after-timeout#f8d523e0)
   Compiling ntest v0.9.2 (ssh://github.com/Darksonn/ntest.git?branch=alice/fix-attrs-after-timeout#f8d523e0)
   Compiling busd v0.3.1 (/home/zeenix/checkout/dbus2/busd)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 7.00s
     Running unittests src/lib.rs (target/debug/deps/busd-5ed485571a7a749c)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/bin/busd.rs (target/debug/deps/busd-ad2ae5830c2d6126)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/fdo.rs (target/debug/deps/fdo-8c241ea568e50b53)

running 1 test
test name_ownership_changes ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.41s

     Running tests/greet.rs (target/debug/deps/greet-218d32b8d0e2b4a9)

running 1 test
test greet ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.53s

     Running tests/monitor.rs (target/debug/deps/monitor-865400062e83e306)

running 1 test
test become_monitor ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.09s

     Running tests/multiple_conns.rs (target/debug/deps/multiple_conns-dc3fc18a8809f289)

running 1 test
test multi_conenct ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.07s

   Doc-tests busd

running 0 tests

muzarski added a commit to muzarski/scylla-rust-driver that referenced this pull request Jun 12, 2024
We decided to bump minimum required version of tokio to 1.34.

Currently, the newest tokio version is 1.38, but some of the integration
tests are eaten when testing with this specific verstion of tokio.
Which is why, as of now, we decided not to support this version.

The issue with version 1.38 is related
to #[tokio::test] and #[ntest::timeout] attributes.
Refs:
- tokio-rs/tokio#6610
- becheran/ntest#28
- tokio-rs/tokio#6497
muzarski added a commit to muzarski/scylla-rust-driver that referenced this pull request Jun 12, 2024
We decided to bump minimum required version of tokio to 1.34.

Currently, the newest tokio version is 1.38, but some of the integration
tests are eaten when testing with this specific verstion of tokio.
Which is why, as of now, we decided not to support this version.

The issue with version 1.38 is related
to #[tokio::test] and #[ntest::timeout] attributes.
Refs:
- tokio-rs/tokio#6610
- becheran/ntest#28
- tokio-rs/tokio#6497
muzarski added a commit to muzarski/scylla-rust-driver that referenced this pull request Jun 12, 2024
We decided to bump minimum required version of tokio to 1.34.

Currently, the newest tokio version is 1.38, but some of the integration
tests are eaten when testing with this specific verstion of tokio.
Which is why, as of now, we decided not to support this version.

The issue with version 1.38 is related
to #[tokio::test] and #[ntest::timeout] attributes.
Refs:
- tokio-rs/tokio#6610
- becheran/ntest#28
- tokio-rs/tokio#6497
muzarski added a commit to muzarski/scylla-rust-driver that referenced this pull request Jun 12, 2024
We decided to bump minimum required version of tokio to 1.34.

Currently, the newest tokio version is 1.38, but some of the integration
tests are eaten when testing with this specific verstion of tokio.
Which is why, as of now, we decided not to support this version.

The issue with version 1.38 is related
to #[tokio::test] and #[ntest::timeout] attributes.
Refs:
- tokio-rs/tokio#6610
- becheran/ntest#28
- tokio-rs/tokio#6497
@zeenix
Copy link

zeenix commented Jun 18, 2024

I hope this wasn't forgotten. I want to use the latest tokio.

@becheran
Copy link
Owner

Sry for letting you wait. Looks good to me. Thanks for adding tests as well.

Will release a new version ASAP.

@becheran becheran merged commit 53d1aa1 into becheran:master Jun 18, 2024
2 checks passed
@becheran
Copy link
Owner

Fix is part of version 0.9.3

@Darksonn Darksonn deleted the alice/fix-attrs-after-timeout branch June 21, 2024 12:27
rukai added a commit to rukai/scylla-rust-driver that referenced this pull request Jun 24, 2024
This is fine since tokio-rs/tokio#6610 is
resolved via becheran/ntest#28 which has now
been released in ntest 0.9.3
Also bumps the itertools + base64 versions, since they are trivial upgrades
rukai added a commit to rukai/scylla-rust-driver that referenced this pull request Jun 24, 2024
This is fine since tokio-rs/tokio#6610 is
resolved via becheran/ntest#28 which has now
been released in ntest 0.9.3
Also bumps the itertools + base64 versions, since they are trivial upgrades
rukai added a commit to rukai/scylla-rust-driver that referenced this pull request Jun 24, 2024
This is fine since tokio-rs/tokio#6610 is
resolved via becheran/ntest#28 which has now
been released in ntest 0.9.3
Also bumps the itertools + base64 versions, since they are trivial upgrades
rukai added a commit to rukai/scylla-rust-driver that referenced this pull request Jun 24, 2024
This is fine since tokio-rs/tokio#6610 is
resolved via becheran/ntest#28 which has now
been released in ntest 0.9.3
Also bumps the itertools + base64 versions, since they are trivial upgrades
rukai added a commit to rukai/scylla-rust-driver that referenced this pull request Jun 24, 2024
This is fine since tokio-rs/tokio#6610 is
resolved via becheran/ntest#28 which has now
been released in ntest 0.9.3
Also bumps the itertools + base64 versions, since they are trivial upgrades
rukai added a commit to rukai/scylla-rust-driver that referenced this pull request Jun 24, 2024
This is fine since tokio-rs/tokio#6610 is
resolved via becheran/ntest#28 which has now
been released in ntest 0.9.3
Also bumps the itertools + base64 versions, since they are trivial upgrades
rukai added a commit to rukai/scylla-rust-driver that referenced this pull request Jun 24, 2024
This is fine since tokio-rs/tokio#6610 is
resolved via becheran/ntest#28 which has now
been released in ntest 0.9.3
rukai added a commit to rukai/scylla-rust-driver that referenced this pull request Jun 24, 2024
This is fine since tokio-rs/tokio#6610 is
resolved via becheran/ntest#28 which has now
been released in ntest 0.9.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

regression: tokio::test in 1.38 eats my tests How to use test_case with async/tokio?
3 participants