Skip to content

DRY setup of WorkunitStore in Rust tests#11436

Merged
Eric-Arellano merged 3 commits into
pantsbuild:masterfrom
Eric-Arellano:workunit-init
Jan 12, 2021
Merged

DRY setup of WorkunitStore in Rust tests#11436
Eric-Arellano merged 3 commits into
pantsbuild:masterfrom
Eric-Arellano:workunit-init

Conversation

@Eric-Arellano
Copy link
Copy Markdown
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
Copy Markdown
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.

}))
}

pub fn setup_for_tests() -> WorkunitStore {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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