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

DRY setup of WorkunitStore in Rust tests #11436

Merged
merged 3 commits into from
Jan 12, 2021

Conversation

Eric-Arellano
Copy link
Contributor

[ci skip-build-wheels]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
let workunit_store = WorkunitStore::new(false);
workunit_store.init_thread_state(None);

WorkunitStore::setup_for_tests();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please feel free to bikeshed this method name, especially if there's something more idiomatic in Rust.

@@ -528,6 +528,12 @@ impl WorkunitStore {
}))
}

pub fn setup_for_tests() -> WorkunitStore {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this needs docstring. I didn't know what to put in it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it need not have one .... iff you annotate this with #[cfg(test)].

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
Copy link
Contributor

@tdyas tdyas left a comment

Choose a reason for hiding this comment

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

lgtm

too bad, the Rust test runner doesn't have the notion of setup functions like other test frameworks. (There are crates that do that but this PR is good as-is.)

@Eric-Arellano Eric-Arellano merged commit 8d4182a into pantsbuild:master Jan 12, 2021
@Eric-Arellano Eric-Arellano deleted the workunit-init branch January 12, 2021 19:30
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