Skip to content

Revamped testing guide #19627

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

Merged
merged 1 commit into from
Dec 13, 2014
Merged

Revamped testing guide #19627

merged 1 commit into from
Dec 13, 2014

Conversation

steveklabnik
Copy link
Member

No description provided.

test on windows you can write `#[cfg_attr(windows, ignore)]`.
The second change is the `use` declaration. Because we're in an inner module,
we need to bring our test function into scope. This can be annoying if you have
a large module, and so this is a common use of the `glob` crate.
Copy link
Member

Choose a reason for hiding this comment

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

The glob crate is unrelated to use foo:::*. All you need for that is #![feature(globs)] in the crate root.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah! 😅

@sfackler
Copy link
Member

sfackler commented Dec 8, 2014

cc #19560 - don't want to lose the doc change if that PR merges first.

## Benchmarks and the optimizer
* Move setup code outside the `iter` loop; only put the part you want to measure inside
* Make the code do "the same thing" on each iteration; do not accumulate or change state
* Make the outer function idempotent too; the benchmark runner is likely to run
Copy link
Contributor

Choose a reason for hiding this comment

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

s/idempotent/independent/?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was copied straight from the previous version of the text. Regardless, idempotent is the correct word here: you don't want multiple calls to the test to have different outcomes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh! I didn't realize it was a word.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. I saw that once I saw it was real. Good to know.

@steveklabnik steveklabnik force-pushed the testing_guide branch 2 times, most recently from 70ef7aa to 5d8ff6a Compare December 8, 2014 16:27
@steveklabnik
Copy link
Member Author

@sfackler addressed your comments and included the fixes from your PR.


To create test functions, add a `#[test]` attribute like this:
Let's talk about how to test Rust code. What we will not be talking about the
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing an "is" from this line.

What we will not be talking about is the ...

@steveklabnik steveklabnik force-pushed the testing_guide branch 2 times, most recently from 2bc2574 to 5b11154 Compare December 11, 2014 14:06
brson added a commit to brson/rust that referenced this pull request Dec 12, 2014
@bors bors closed this Dec 13, 2014
@bors bors merged commit d4ea71d into rust-lang:master Dec 13, 2014

## Benchmarks and the optimizer
Copy link
Member

Choose a reason for hiding this comment

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

FWIW, it's a little sad to lose the headings, since it's useful to link people directly to this optimisation section when they encounter a optimised-out benchmark.

Copy link
Member Author

Choose a reason for hiding this comment

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

@huonw mind opening up a new issue with these comments? this already got merged, and I'm not going to get to them tonight, and I don't want to lose them :)

@huonw huonw mentioned this pull request Dec 15, 2014
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.

6 participants