Skip to content

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

Merged
merged 8 commits into from
Feb 21, 2018
Merged

created compiletest.md #53

merged 8 commits into from
Feb 21, 2018

Conversation

U007D
Copy link

@U007D U007D commented Feb 13, 2018

describe the steps required to add a test and a header command to compiletest

describe the steps required to add a test and a header command to compiletest
Copy link
Member

@mark-i-m mark-i-m left a comment

Choose a reason for hiding this comment

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

Thanks! I think this chapter will nicely complement #47! (I think it might be a good idea to wait for #47 to merge so that we can update links between the chapters more easily)

I left a few comments below.

Also, could you update SUMMARY.md, so this appears in the ToC?

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
Copy link
Member

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)

Copy link
Author

Choose a reason for hiding this comment

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

done

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).
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 we should also link to the chapter that will be added in #47

Copy link
Author

@U007D U007D Feb 13, 2018

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?

Copy link
Member

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.

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).
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 this can be a link to the chapter from #47

Copy link
Author

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?

Copy link
Member

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.

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 you missed this one

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
Copy link
Member

Choose a reason for hiding this comment

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

"every parsers" -> "every parser"

Copy link
Author

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
Copy link
Member

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 😂

Copy link
Author

Choose a reason for hiding this comment

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

:)

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
Copy link
Member

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 --.

Copy link
Author

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.


As a concrete example, here is the implementation for the `parse_failure_status()` parser, in
`src/tools/compiletest/src/header.rs`:
```diff
Copy link
Member

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 👍

Copy link
Author

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?

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
Copy link
Member

Choose a reason for hiding this comment

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

"ommand" -> "command"

Copy link
Author

Choose a reason for hiding this comment

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

fixed

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
Copy link
Member

Choose a reason for hiding this comment

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

"hange" -> "change"

Copy link
Author

@U007D U007D Feb 13, 2018

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? :)

Copy link
Member

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"...

@U007D
Copy link
Author

U007D commented Feb 13, 2018

All feedback addressed (except link to PR#47, pending your reply).

@mark-i-m
Copy link
Member

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!

@U007D
Copy link
Author

U007D commented Feb 13, 2018

Agreed. All cool by me! And thanks for the proof-read!

@mark-i-m mark-i-m added the S-blocked Status: this PR is blocked waiting for something label Feb 15, 2018
@mark-i-m
Copy link
Member

@U007D #47 has landed 🎉

A few comments

Thanks!

@mark-i-m mark-i-m added S-waiting-on-author Status: this PR is waiting for additional action by the OP and removed S-blocked Status: this PR is blocked waiting for something labels Feb 17, 2018
@U007D
Copy link
Author

U007D commented Feb 18, 2018 via email

@U007D U007D mentioned this pull request Feb 20, 2018
@U007D
Copy link
Author

U007D commented Feb 20, 2018

#61

Copy link
Member

@mark-i-m mark-i-m left a 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!

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).
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 we should also link to the "Adding tests" chapter here.

Copy link
Author

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.

Copy link
Author

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...

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 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.

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).
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 you missed this one

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,
Copy link
Member

Choose a reason for hiding this comment

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

s/hange/change/

Copy link
Author

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! :)

@U007D
Copy link
Author

U007D commented Feb 21, 2018

Also improved some language under Adding a new header command.

@mark-i-m mark-i-m merged commit 238b190 into rust-lang:master Feb 21, 2018
@mark-i-m
Copy link
Member

Thanks!

@U007D U007D deleted the compiletest branch February 21, 2018 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: this PR is waiting for additional action by the OP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants