Skip to content

Enable ignoring tests based on architecture. #19809

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

Closed

Conversation

akosthekiss
Copy link
Contributor

Now, tests can only be ignored on OS basis. However, some tests - e.g., compile-fail/asm-misplaced-option.rs - should be skipped because of the target architecture.

(Note: in the case of compile-fail/asm-misplaced-option.rs, #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub fn main() prevents the Intel assembly to be processed on another architecture but does not prevent compiletest to find and expect the warnings within main.)

So, this PR proposes to enhance compiletest to recognize // ignore-ARCH lines as well.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pcwalton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see CONTRIBUTING.md for more information.

@@ -34,6 +43,15 @@ pub fn get_os(triple: &str) -> &'static str {
panic!("Cannot determine OS from triple");
}

pub fn get_arch(triple: &str) -> &'static str {
for &triple_arch in ARCH_TABLE.iter() {
if triple.contains(triple_arch) {
Copy link
Member

Choose a reason for hiding this comment

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

Because x86_64 contains x86, doesn't this mean that // ignore-x86 will ignore 32 and 64 bit platforms?

…h can correctly determine the architecture.

(So, x86_64 will not be identified as x86, and mipsel will not be identified as mips.)
@akosthekiss
Copy link
Contributor Author

You're right, I've missed that case. (And the same applies to mipsel/mips). So, I've reordered ARCH_TABLE so that substrings come later. This way, get_arch() will check for and find x86_64 first.

(Also, I forgot to update the copyright line in the touched files, which is suggested by the guidelines. Fixed that now.)

@alexcrichton
Copy link
Member

With just a check of .contains I think that // ignore-x86 will still trip for x86_64 because it contains the string x86.

@akosthekiss
Copy link
Contributor Author

In case of util::get_arch("x86_64-unknown-linux-gnu"), the first element in ARCH_TABLE that will yield true for triple.contains(triple_arch) is "x86_64". And then the function returns. If the function gets "x86-unknown-linux-gnu", then only "x86" will give ok for .contains. If I'm right.

Another alternative would be return triple.as_slice().split('-').next(). Might as well be simpler?

Unfortunately, you may still be right, because of header::parse_name_directive. If util::get_arch returns "x86" (by whichever implementation), then it will look for ignore-x86 and will find it in // ignore-x86_64 lines as well... (I'm not sure yet how to fix that...)

@alexcrichton
Copy link
Member

Triples are known to have a - character after the architecture, so it's fine to search for $arch- which should prevent this sort of prefix ambiguity.

…le by splitting at '-' (instead of relying on tables and .contains).

This makes previous changes to util.rs unnecessary.
@@ -209,7 +213,8 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {

let val = iter_header(testfile, |ln| {
!parse_name_directive(ln, "ignore-test") &&
!parse_name_directive(ln, ignore_target(config).as_slice()) &&
!parse_name_directive(ln, ignore_os(config).as_slice()) &&
!parse_name_directive(ln, ignore_arch(config).as_slice()) &&
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately due to the use of .contains in parse_name_directive I think this suffers the same problem as before :(

@Gankra
Copy link
Contributor

Gankra commented Jan 2, 2015

@akiss77 status?

@emberian
Copy link
Member

emberian commented Jan 5, 2015

Closing due to inactivity. Feel free to update and reopen, though!

@emberian emberian closed this Jan 5, 2015
lnicola pushed a commit to lnicola/rust that referenced this pull request May 20, 2025
internal: Catch panics in inference in analysis-stats
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