-
Notifications
You must be signed in to change notification settings - Fork 543
created compiletest.md #53
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
Conversation
describe the steps required to add a test and a header command to compiletest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/compiletest.md
Outdated
The tests themselves are typically (but not always) organized into "suites"--for example, `run-pass`, a folder | ||
representing tests that should succeed, `run-fail`, a folder holding tests that should compile successfully, but return | ||
a failure (non-zero status), `compile-fail`, a folder holding tests that should fail to compile, and many more. The various | ||
suites are defined in `src/tools/compiletest/src/common.rs` in the `pub struct Config` declaration. And a very good |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make this a link to GitHub? That way, the CI will check if the link breaks. (And the same for other references to specific files/folders in the repo)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/compiletest.md
Outdated
a failure (non-zero status), `compile-fail`, a folder holding tests that should fail to compile, and many more. The various | ||
suites are defined in `src/tools/compiletest/src/common.rs` in the `pub struct Config` declaration. And a very good | ||
introduction to the different suites of compiler tests along with details about them can be found | ||
[here, at Brian Anderson's blog](https://brson.github.io/2017/07/10/how-rust-is-tested#s-ct). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also link to the chapter that will be added in #47
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want a link in the doc to the PR or to wait until it lands and can be linked to under master
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to wait until it lands and can be linked to under master
I think this would be best, unless you are under a time constraint.
src/compiletest.md
Outdated
commands. These commands can instruct `compiletest` to ignore this test, set expectations on whether it is expected to | ||
succeed at compiling, or what the test's return code is expected to be. Header commands (and their inline counterparts, | ||
Error Info commands) are described more fully | ||
[here](https://github.com/rust-lang/rust/blob/master/src/test/COMPILER_TESTS.md). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be a link to the chapter from #47
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want a link in the doc to the PR or to wait until it lands and can be linked to under master
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to wait until it lands and can be linked to under master
I think this would be best, unless you are under a time constraint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you missed this one
src/compiletest.md
Outdated
property to its default value. | ||
|
||
#### Adding a new header command parser | ||
When `compiletest` encounters a test file, it parses the file a line at a time by calling every parsers defined in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"every parsers" -> "every parser"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Parsers will override a given header command property's default value merely by being specified in the test file as a header | ||
command or by having a parameter value specified in the test file, depending on the header command. | ||
|
||
Parsers defined in `impl Config` are typically named `parse_<header_command>` (note kebab-case `<header-command>` transformed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol! I have never heard it called kebab-case before 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
src/compiletest.md
Outdated
to snake-case `<header_command>`). `impl Config` also defines several 'low-level' parsers which make it simple to parse | ||
common patterns like simple presence or not (`parse_name_directive()`), header-command:parameter(s) | ||
(`parse_name_value_directive()`), optional parsing only if a particular `cfg` attribute is defined (`has_cfg_prefix()`) and | ||
many more. The low-level parsers are found near the end of the `impl Config` block--be sure to look through them and their |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: everywhere else, we have been using -
instead of --
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just looked up em-dash vs en-dash to check for correct usage; it seems correct with two hyphens, but I've changed it to a ; to address your concern.
src/compiletest.md
Outdated
|
||
As a concrete example, here is the implementation for the `parse_failure_status()` parser, in | ||
`src/tools/compiletest/src/header.rs`: | ||
```diff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of a cool use for diff formatting 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's nice, eh?
src/compiletest.md
Outdated
is that `compiletest` expects the failure code defined by the header command invoked in the test, rather than the default | ||
value. | ||
|
||
Although specific to `failure-status` (as every header ommand will have a different implementation in order to invoke |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ommand" -> "command"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/compiletest.md
Outdated
value. | ||
|
||
Although specific to `failure-status` (as every header ommand will have a different implementation in order to invoke | ||
behavior change) perhaps it is helpful to see the behavior hange implementation of one case, simply as an example. To |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"hange" -> "change"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. weird; why am I leaving out so many first letters? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And they are both "c"...
changed file references to GitHub links directly to files
All feedback addressed (except link to PR#47, pending your reply). |
LGTM 👍 I think we should wait for #47 unless you are under time constraints because that will make it easier to link to the other chapter. Thanks! |
Agreed. All cool by me! And thanks for the proof-read! |
A few comments
Thanks! |
Great, glad to hear it!
Re: edits: Sure. I'll see what I can do to make the edits over the next few days, and will let you know once they're done.
…-------- Original Message --------
On February 17, 2018 8:55 AM, Who? Me?! ***@***.***> wrote:
***@***.***(https://github.com/u007d) [#47](#47) has landed 🎉
A few comments
- Perhaps we can move this chapter to be a subchapter in the SUMMARY?
- Perhaps we can add links to this chapter in https://github.com/rust-lang-nursery/rustc-guide/blob/master/src/tests/adding.md and https://github.com/rust-lang-nursery/rustc-guide/blob/master/src/tests/intro.md
- Could you update this chapter to link to those chapters?
Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, [view it on GitHub](#53 (comment)), or [mute the thread](https://github.com/notifications/unsubscribe-auth/ACvebZE5zMNMwKNVYnkSgE0nHyvDwWG8ks5tVwR4gaJpZM4SDyMw).
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks :)
I left three minor comments, then r=me!
src/compiletest.md
Outdated
a failure (non-zero status), `compile-fail`, a folder holding tests that should fail to compile, and many more. The various | ||
suites are defined in [src/tools/compiletest/src/common.rs](https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/common.rs) in the `pub struct Config` declaration. And a very good | ||
introduction to the different suites of compiler tests along with details about them can be found | ||
[here, at Brian Anderson's blog](https://brson.github.io/2017/07/10/how-rust-is-tested#s-ct). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also link to the "Adding tests" chapter here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a bit weird to me to provide the same link that we provide in the next paragraph... Plus, we're not even talking about adding tests in this paragraph.
LMK if you'd still like to link to Adding tests here, and if you'd like it alongside or instead of the link to @brson's blog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I think about it more, I suppose it's also weird to provide two different authoritative sources on a topic... ;) I think I'll just replace the brson link. LMK if you have other thoughts...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there sounds reasonable. There is already a link to brsons post in the other chapter, so let's just point to the other chapter everywhere.
src/compiletest.md
Outdated
commands. These commands can instruct `compiletest` to ignore this test, set expectations on whether it is expected to | ||
succeed at compiling, or what the test's return code is expected to be. Header commands (and their inline counterparts, | ||
Error Info commands) are described more fully | ||
[here](https://github.com/rust-lang/rust/blob/master/src/test/COMPILER_TESTS.md). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you missed this one
src/compiletest.md
Outdated
value. | ||
|
||
Although specific to `failure-status` (as every header command will have a different implementation in order to invoke | ||
behavior change) perhaps it is helpful to see the behavior hange implementation of one case, simply as an example. To implement `failure-status`, the `check_correct_failure_status()` function found in the `TestCx` implementation block, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/hange/change/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow. Something was definitely wrong with my 'c' finger that day! :)
Also improved some language under Adding a new header command. |
Thanks! |
describe the steps required to add a test and a header command to compiletest