Skip to content

Generate a separate test function for every header #261

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
Nov 15, 2016

Conversation

jdub
Copy link
Contributor

@jdub jdub commented Nov 15, 2016

  • Header tests can now be run selectively, e.g.
    cargo test header will test all headers
    cargo test union will test headers with 'union' in the file name
  • The list of test functions is generated by build.rs, so never needs to be updated
  • Clever approach suggested by @fitzgen

This PR depends on #204, so will include those changes until they're merged into master and this can be rebased. But I'll keep the commits separate.

@highfive
Copy link

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

.replace(|c| !char::is_alphanumeric(c), "_")
.replace("__", "_")
.to_lowercase();
let _ = writeln!(dst, "test_header!(header_{}, {:?});",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think You need to write these in a block to avoid rust-lang/rust#35560

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The include!() is not itself in a function, so it just pulls in a bunch of test function definitions, and doesn't interact with that bug. I'm getting the same pass/fail rate as #204, only pretty. 😄

test result: FAILED. 120 passed; 1 failed; 0 ignored; 0 measured

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, sounds good then :)

Do you plan to land everything here (and thus close #204), or splitting the last commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll rebase this once #204 has landed -- further comments over there. :-)

@emilio
Copy link
Contributor

emilio commented Nov 15, 2016

In any case, just update the test for now, let's get this landed, and then polish it later :)

@bors-servo
Copy link

☔ The latest upstream changes (presumably #263) made this pull request unmergeable. Please resolve the merge conflicts.

- Header tests can now be run selectively, e.g. `cargo test union`
  will test all headers with 'union' in the file name.
- The list of test functions is generated by `build.rs`, so never
  needs to be updated.
- Clever approach suggested by @fitzgen.
@emilio
Copy link
Contributor

emilio commented Nov 15, 2016

@bors-servo r+

@bors-servo
Copy link

📌 Commit a6aa516 has been approved by emilio

@bors-servo
Copy link

⌛ Testing commit a6aa516 with merge 09dc05c...

bors-servo pushed a commit that referenced this pull request Nov 15, 2016
Generate a separate test function for every header

- Header tests can now be run selectively, e.g.
  `cargo test header` will test all headers
  `cargo test union` will test headers with 'union' in the file name
- The list of test functions is generated by `build.rs`, so never needs to be updated
- Clever approach suggested by @fitzgen

This PR depends on #204, so will include those changes until they're merged into master and this can be rebased. But I'll keep the commits separate.
@fitzgen
Copy link
Member

fitzgen commented Nov 15, 2016

Thanks for doing this one too :-D

@bors-servo
Copy link

☀️ Test successful - status-travis

@bors-servo bors-servo merged commit a6aa516 into rust-lang:master Nov 15, 2016
@jdub jdub deleted the named-tests branch November 15, 2016 20:03
luser pushed a commit to luser/rust-bindgen that referenced this pull request Mar 27, 2017
Don't derive debug on a struct if one of it's members isn't Debug.

Add a new test for this case.

Fixes rust-lang#261
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