Skip to content

Update extract-tests.py to use same test directives as rustdoc. #11490

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
Jan 28, 2014

Conversation

wting
Copy link
Contributor

@wting wting commented Jan 12, 2014

Refactored the file quite a bit, I can add unit tests if desired. There's a few changes from the previous version's behavior:

  • destination directory will be created if it doesn't exist
  • strings and file is written as unicode

I have a few questions, but will ask them in #11362.

@wting
Copy link
Contributor Author

wting commented Jan 12, 2014

Updated following brson's comments in #11362.

{ .should_fail } results in //should-fail at the top of the resulting .rs file. { .xfail-test } results in a similar //xfail-test.

@adrientetar
Copy link
Contributor

There is one thing that would be cool (additionally): checking if there are crate-level compiler attributes at the top of the file #[foo()]; (w/ the semicolon) and if so only append extern mod extra; after that attribute.
Right now, if we want to add a crate-level attr to a code example we have to add extern mod extra; directive first so that they're not invalidated.

For example, this is not valid:

extern mod extra;
#[allow(unused_imports)];

I had to add a trailing extern mod extra; in the Conditions Guide to workaround this, and it is hacky (also annoying when you don't know about it).

So that makes me wondering: why not just drop the extern mod extra business and add it manually in the relevant examples? (cc @brson)

@wting
Copy link
Contributor Author

wting commented Jan 12, 2014

It looks like compiler attributes can be multiple lines. Should I worry about this case?

@wting
Copy link
Contributor Author

wting commented Jan 13, 2014

Updated with support for single line compiler directives. More specifically matches the regex #[(.*)];.

Also removed unnecessary extern mod extra; lines from guide-conditions.md.


# tags to ignore
IGNORE_TAGS = \
frozenset(["ignore", "ebnf", "abnf", "keyword", "field", "precedence"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't the docs also use 'notrust'?

@brson
Copy link
Contributor

brson commented Jan 13, 2014

Thanks. This is awesome work. I'd like to request just a little bit more here before merging. The ultimate intent here is to bring all our testing tools inline to the same terminology. To that end can you remove extract-test.py's support for 'xfail-test' completely, and instead of having it ignore the 'ignore' tag make it turn 'ignore' into '//xfail-test' when emitting the tests? (I know this sounds completely counterintuitive on the surface but in most of our testing tools 'ignore' means 'this is a test that is broken' - the next step is to probably change compiletest to also use 'ignore' and not 'xfail-test').

Additional next steps (that you don't have to do now): modify compiletest to understand 'should-fail'. Go through all the currently disabled doc tests convert those that appropriate to should_fail.

@brson brson mentioned this pull request Jan 13, 2014
@adrientetar
Copy link
Contributor

This is really cool work @wting, thanks!

@wting
Copy link
Contributor Author

wting commented Jan 15, 2014

  • add notrust to ignored tags
  • remove xfail-test tag support
  • ignore tag now generates //xfail-test

@brson
Copy link
Contributor

brson commented Jan 17, 2014

I'll test this locally tomorrow. I suspect that removing xfail-test parsing will cause all the current snippets marked xfail-test to start failing; they should now be ignore.

@brson
Copy link
Contributor

brson commented Jan 17, 2014

Indeed, the current .xfail-test tags in the doc/ folder need to be converted to .ignore so that they continue to be ignored. @wting can you do so?

@wting
Copy link
Contributor Author

wting commented Jan 18, 2014

Yeah I'll update it by Monday.

@wting
Copy link
Contributor Author

wting commented Jan 18, 2014

All .xfail-test tags in doc/*.md and doc/*.md.po files have been converted to .ignore tag.

@wting
Copy link
Contributor Author

wting commented Jan 21, 2014

@brson: bump for review.

@alexcrichton
Copy link
Member

This appears to need a rebase again, sorry about that? Feel free to ping me on a rebase and I'll r+ this

@wting
Copy link
Contributor Author

wting commented Jan 23, 2014

@alexcrichton: Rebased.

@adrientetar
Copy link
Contributor

@wting Have you looked at the log?
It looks like you forgot some .xfail-test.ignore in some spots in guide-ffi.md.

(I would grep again through source to see if there aren't other places where it got missed.)

@wting
Copy link
Contributor Author

wting commented Jan 28, 2014

Thanks for the catch @adridu59. I think I missed some of the xfail-test after rebasing but I've updated the patch accordingly.

@wting
Copy link
Contributor Author

wting commented Jan 28, 2014

Earlier I did a fetch and rebase on mozilla/rust, thought it was a legitimate submodule bump. Anyway I've gone ahead and reverted the llvm submodule pointer back to 535989a9.

@alexcrichton
Copy link
Member

Could you squash the two commits together?

@wting
Copy link
Contributor Author

wting commented Jan 28, 2014

Squashed!

bors added a commit that referenced this pull request Jan 28, 2014
…=alexcrichton

Refactored the file quite a bit, I can add unit tests if desired. There's a few changes from the previous version's behavior:

- destination directory will be created if it doesn't exist
- strings and file is written as unicode

I have a few questions, but will ask them in #11362.
@bors bors merged commit 9f60e7c into rust-lang:master Jan 28, 2014
@wting wting deleted the wting_11362_update_extract_tests branch February 14, 2014 15:22
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 25, 2022
Revert rust-lang#11490

Closes rust-lang#11725

rust-lang#11490 was a little misguided. Quoting the test name should be a client concern, since it's the client that actually runs `cargo`.
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.

5 participants