Skip to content

Add ‘#[serial]’ tests (v2)#42684

Closed
shivjm wants to merge 7 commits into
rust-lang:masterfrom
shivjm:add-serial-tests-v2
Closed

Add ‘#[serial]’ tests (v2)#42684
shivjm wants to merge 7 commits into
rust-lang:masterfrom
shivjm:add-serial-tests-v2

Conversation

@shivjm

@shivjm shivjm commented Jun 15, 2017

Copy link
Copy Markdown

(Fixed version of #42626; sorry for the noise.)

This PR adds a #[serial] attribute that marks tests that should be executed one-by-one rather than concurrently (per #33519).

I’ve confirmed that the libtest and tidy tests pass. I wasn’t able to run the full suite as a lot of the run_make tests seem to fail on my Windows system, but everything passed up to that point.

Rust (and PR!) newbie here, so please do let me know if I’m doing something poorly or incorrectly!

@rust-highfive

Copy link
Copy Markdown
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@leonardo-m

Copy link
Copy Markdown

Perhaps a name like #[serial_test] is better?

@Mark-Simulacrum

Copy link
Copy Markdown
Member

I think #[serial] is fine given that #[test] will also be there, but I could see an argument being made that serial is too generic a name. I do think this needs a feature gate though, which I believe hasn't yet been implemented. I could be wrong though.

@shivjm

shivjm commented Jun 15, 2017

Copy link
Copy Markdown
Author

Ah, I didn’t understand how the feature gates work and the example I followed (#42219) is apparently a WIP. Looking at #42088, I need to gate this by:

  1. Adding an entry to the declare_features block in feature_gate.rs with a feature name, a version, and an issue number:
(active, serial_tests, "1.19.0", Some(42684))
  1. Specifying AttributeGate::Gated for the serial attribute in BUILTIN_ATTRIBUTES (same file), which needs a feature name, an explanation, and a function to check its configuration (auto-generated using cfg_fn):
("serial", Normal, Gated(Stability::Unstable, "serial_tests", "the `#[serial]` attribute is an experimental feature", cfg_fn!(serial_tests))
  1. Adding a new document under unstable-book/src/language-features/ that points to this PR.
  2. Adding an entry under unstable-book/src/SUMMARY.md that points to that document.

Is this correct? Have I missed anything? I’ll try to get it done pronto, but if not, it will be about a week.

Re: the name of the attribute itself, I can change that if serial is too generic.

@shepmaster shepmaster added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 16, 2017

@bjorn3 bjorn3 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Few minor things. Overal code looks good to me.

Comment thread src/libsyntax/test.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please end the line with a comma, so there is less noise when new fields get added.

Comment thread src/libsyntax/test.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here

Comment thread src/libtest/lib.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here

Comment thread src/libtest/lib.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here

Comment thread src/libtest/lib.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please print the result too. Eg

panic!("result not okay: {:?}", result),

Comment thread src/libtest/lib.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same printing thing here.

@bors

bors commented Jun 21, 2017

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #42664) made this pull request unmergeable. Please resolve the merge conflicts.

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 25, 2017
@Mark-Simulacrum

Copy link
Copy Markdown
Member

@shivjm I believe this is waiting on some changes from you and a rebase. Let us know if we can help in any way! Feel free to ping me on IRC (simulacrum).

@shivjm

shivjm commented Jun 25, 2017

Copy link
Copy Markdown
Author

Sorry, been out of town and then busy catching up! I’ve rebased the PR and (I hope) fixed the issues @bjorn3 pointed out (thanks!). Next up, need to implement the feature gate. I’ll ask for help on IRC.

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 25, 2017
@shivjm

shivjm commented Jun 25, 2017

Copy link
Copy Markdown
Author

I’ve added the serial_tests feature gate. @est31, does this need an entry under unstable-book as well?

@est31

est31 commented Jun 26, 2017

Copy link
Copy Markdown
Member

does this need an entry under unstable-book as well?

The requirement for an entry has been removed. You can add one (with meaningful content) if you want to, if not, a stub will be generated automatically.

@bjorn3 bjorn3 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lgtm when the trailing newline is added.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add a trailing newline.

@shivjm

shivjm commented Jun 26, 2017

Copy link
Copy Markdown
Author

Done, thanks!

@brson brson added T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. I-nominated labels Jun 27, 2017
@brson

brson commented Jun 27, 2017

Copy link
Copy Markdown
Contributor

Thanks for the patch.

This probably needs more discussion before landing. This is a thing that we've declined to do for many years.

@brson

brson commented Jun 27, 2017

Copy link
Copy Markdown
Contributor

cc @nrc

@bors

bors commented Jun 29, 2017

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #42964) made this pull request unmergeable. Please resolve the merge conflicts.

@shivjm

shivjm commented Jul 3, 2017

Copy link
Copy Markdown
Author

Is there anything I can do to help?

@bors

bors commented Jul 6, 2017

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #42727) made this pull request unmergeable. Please resolve the merge conflicts.

@nrc

nrc commented Jul 10, 2017

Copy link
Copy Markdown
Member

@brson do you have links to previous discussion or could you summarise here please? My opinion (uninformed by previous discussion) is that this is something I've wanted personally and I don't see why we should not support it (as long as it is feature gated etc.) being its own attribute feels kind of wrong (I'd prefer to attach it to #[test], but I suppose that #[should_panic] is a precedent?)

@nrc

nrc commented Jul 10, 2017

Copy link
Copy Markdown
Member

Discussed at the dev-tools meeting today, this problem can be solved today using a mutex (I filed #43155 to document that). Given that this solution feels somewhat ad hoc and there is workaround, we would prefer to punt on adding this in favour of custom test runners or some other long-term solution.

Thanks for the PR @shivjm and sorry to close it out after your work.

@shivjm

shivjm commented Jul 11, 2017 via email

Copy link
Copy Markdown
Author

@yshui

yshui commented Feb 21, 2018

Copy link
Copy Markdown
Contributor

@nrc I don't see why this shouldn't be implemented in the test framework. The mutex work around seems to have some catches, and is non-trivial to get right.

@yshui yshui unassigned brson Feb 21, 2018
@DevQps

DevQps commented Apr 5, 2019

Copy link
Copy Markdown
Contributor

For everyone getting to this point: This solution is also implemented in a separate crate now: serial_test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.