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

BTree: share panicky test code & test panic during clear, clone #81300

Merged
merged 2 commits into from
Feb 21, 2021

Conversation

ssomers
Copy link
Contributor

@ssomers ssomers commented Jan 23, 2021

Bases almost all tests of panic on the same, richer definition, and extends it to cloning to test panic during clone.

r? @Mark-Simulacrum

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 23, 2021
@ssomers ssomers changed the title BTreeMap/BTreeSet: share more test code BTreeMap/BTreeSet: test panic during clone & share panicky test code Jan 23, 2021
@@ -0,0 +1,67 @@
#[doc(hidden)]
#[macro_export]
macro_rules! crash_test_dummy_def {
Copy link
Member

Choose a reason for hiding this comment

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

I think instead of a macro we can move CLONES and DROPS to Arc fields inside the CrashTestDummy struct and then just have a regular module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand. How can such fields be initialized and point to something particular for each test case, without a macro? I could do it by explicitly passing an instance of some manager to every CrashTestDummy instance, just like in ord_chaos.rs, but then a simple reference is fine.

Note that all of these tests, including the ones I pilfered the code template from, are totally single threaded. They just use atomics to avoid scary unsafe blocks accessing globals.

Copy link
Member

Choose a reason for hiding this comment

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

A reference would also be fine.

@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 Jan 24, 2021
@ssomers
Copy link
Contributor Author

ssomers commented Jan 27, 2021

@rustbot label: +S-waiting-on-review -S-waiting-on-author

@rustbot rustbot 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 Jan 27, 2021

#[derive(Debug)]
pub struct Scene {
bits_per_id: usize,
Copy link
Member

Choose a reason for hiding this comment

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

Can we add some kind of comment explaining this struct?

In particular it's not clear what value should be passed for bits_per_id or what that means, but more broadly a top-level comment here describing usage would be helpful.

@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 Jan 28, 2021
@ssomers ssomers force-pushed the btree_cleanup_leak_tests branch 2 times, most recently from 991bf7d to 440d869 Compare January 31, 2021 15:19
@bors
Copy link
Contributor

bors commented Feb 5, 2021

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

@ssomers
Copy link
Contributor Author

ssomers commented Feb 5, 2021

@rustbot label: +S-waiting-on-review -S-waiting-on-author

@rustbot rustbot 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 Feb 5, 2021
@ssomers ssomers changed the title BTreeMap/BTreeSet: test panic during clone & share panicky test code BTree: share panicky test code & test panic during clear, clone Feb 5, 2021
}

/// Returns how many times a dummy has been queried. If set up by `new`,
/// this is a hexadecimal composition of the count for each dummy id.
Copy link
Member

Choose a reason for hiding this comment

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

Can we add an example or documentation on what a hexadecimal composition means to the CrashTest struct? It sounds like what this is doing is splitting the u64 into 16 "sections", each 4 bits large, which enables us to track the number for each of those sections (up to 15, I guess). But I'm a bit confused as to why we need something so complicated over a vector of atomics, for example, or even a Mutex<Vec<u64>> - I don't think we care about performance here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see the complication, but I'm also familiar with binary coded decimal registers. Instead I think involving a mutex complicates matters. Involving a vector probably simplifies, but it is (another) dependency of the btree test code on a cousin in the crate - to some degree, testing the branch you're sitting on. Given the simple use case, I prefer to pull the counters apart in individual local variables and leave the mapping over to the compiler.

The way you comment "up to 15, I guess" suggest to me you didn't notice that I tried to document that same point in the CrashTest::new member, and neither of us noticed I incorrectly said it's limited to 16, so I'm strengthened in my belief there's already too much documentation here.

Anyway, I think the next iteration away from the original is substantially better.

@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 Feb 8, 2021
@ssomers
Copy link
Contributor Author

ssomers commented Feb 18, 2021

@rustbot label: +S-waiting-on-review -S-waiting-on-author

@rustbot rustbot 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 Feb 18, 2021
@Mark-Simulacrum
Copy link
Member

Agreed that this looks much better, thanks. @bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 20, 2021

📌 Commit 3e1d602 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 20, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Feb 21, 2021
…=Mark-Simulacrum

BTree: share panicky test code & test panic during clear, clone

Bases almost all tests of panic on the same, richer definition, and extends it to cloning to test panic during clone.

r? `@Mark-Simulacrum`
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Feb 21, 2021
…=Mark-Simulacrum

BTree: share panicky test code & test panic during clear, clone

Bases almost all tests of panic on the same, richer definition, and extends it to cloning to test panic during clone.

r? ``@Mark-Simulacrum``
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 21, 2021
Rollup of 11 pull requests

Successful merges:

 - rust-lang#81300 (BTree: share panicky test code & test panic during clear, clone)
 - rust-lang#81706 (Document BinaryHeap unsafe functions)
 - rust-lang#81833 (parallelize x.py test tidy)
 - rust-lang#81966 (Add new `rustc` target for Arm64 machines that can target the iphonesimulator)
 - rust-lang#82154 (Update RELEASES.md 1.50 to include methods stabilized in rust-lang#79342)
 - rust-lang#82177 (Do not delete bootstrap.exe on Windows during clean)
 - rust-lang#82181 (Add check for ES5 in CI)
 - rust-lang#82229 (Add [A-diagnostics] bug report template)
 - rust-lang#82233 (try-back-block-type test: Use TryFromSliceError for From test)
 - rust-lang#82302 (Remove unsafe impl Send for CompletedTest & TestResult)
 - rust-lang#82349 (test: Print test name only once on timeout)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3219a10 into rust-lang:master Feb 21, 2021
@rustbot rustbot added this to the 1.52.0 milestone Feb 21, 2021
@ssomers ssomers deleted the btree_cleanup_leak_tests branch February 21, 2021 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants