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

Always use a timeout calling Poll::poll in tests #1230

Closed
wants to merge 1 commit into from

Conversation

Thomasdezeeuw
Copy link
Collaborator

@Thomasdezeeuw Thomasdezeeuw commented Dec 18, 2019

This is to prevent #1226 from happening too some extend, see the docs of NO_TIMEOUT in tests/util/mod.rs.

Copy link
Contributor

@dtacalau dtacalau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I understand the problem this patch is trying to fix, I think the patch has its own problems:

poll(None) vs poll(timeout) exercise different code paths. Removing all poll(None) from tests means its code paths are no longer tested.
Having an assert(Poll(timeout)) failing doesn't seem more data than knowing a Poll(None) hangs.
Maybe the CI can be configured to terminate a test earlier than 1 hour?

@kleimkuhler
Copy link
Contributor

@dtacalau Brings up a good point about testing the None case for Poll::poll. I'd like to see this change go in, but maybe add a simple test that still uses None and expect an event event that should reliably happen? It wouldn't need need to be anything that tests additional behavior.

@Thomasdezeeuw
Copy link
Collaborator Author

I agree with @dtacalau and been looking into other solutions. I found the --ensure-time flag which:

Treat excess of the test execution time limit as
error.
Threshold values for this option can be configured via
RUST_TEST_TIME_UNIT, RUST_TEST_TIME_INTEGRATION
and
RUST_TEST_TIME_DOCTEST environment variables.
Expected format of environment variable is
VARIABLE=WARN_TIME,CRITICAL_TIME.
CRITICAL_TIME here means the limit that should not
be exceeded by test.

See cargo test -- --help. But its a nightly compiler only thing, see rust-lang/rust#64873 and rust-lang/rust#64888. I haven't been able to get it to actually run with the flag set.

@Thomasdezeeuw
Copy link
Collaborator Author

Oh you need to pass -Zunstable-options. But still will only work on nightly only compilers.

@Thomasdezeeuw
Copy link
Collaborator Author

--ensure-time won't work at all as the test isn't interrupted, so we do need a change like this.

Or we could just use the timeout command.

@kleimkuhler
Copy link
Contributor

@Thomasdezeeuw Unfortunately it doesn't look like there is a great alternative for that on Windows. It looks like it some kind of equivalent could be used if CI was setup to run through Powerhsell?

@Thomasdezeeuw
Copy link
Collaborator Author

Not doing it this way and I haven't found an alternative to timeout on Windows/macOS.

@Thomasdezeeuw Thomasdezeeuw deleted the always_timeout branch October 7, 2020 16:03
@Thomasdezeeuw
Copy link
Collaborator Author

Something the following could work in the future.

RUST_TEST_TIME_UNIT="5000,5000" RUST_TEST_TIME_INTEGRATION="5000,5000" RUST_TEST_TIME_DOCTEST="5000,5000" cargo test --all-features -- -Z unstable-options --ensure-time

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.

3 participants