Skip to content

Add regression tests for diagnostic processing. #489

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 2 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions clang/test/3C/diag_verifier_fail.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Test that the diagnostic verifier is functioning correctly in 3c, because if
// it isn't, all the other regression tests that use the diagnostic verifier may
// not be able to catch the problems they are supposed to catch.
//
// This is exactly the same as diag_verifier_pass.c except that the warning
// message we expect is deliberately wrong, so the diagnostic verifier should
// fail.

// RUN: rm -rf %t*
// RUN: not 3c -base-dir=%S -extra-arg="-Wno-everything" -verify -warn-root-cause %s -- 2>%t.stderr
// RUN: grep -q "error: 'warning' diagnostics expected but not seen:" %t.stderr
// RUN: grep -q "error: 'warning' diagnostics seen but not expected:" %t.stderr

// Example warning borrowed from root_cause.c .
void *x; // expected-warning {{Default oops* type}}
15 changes: 15 additions & 0 deletions clang/test/3C/diag_verifier_pass.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Test that the diagnostic verifier is functioning correctly in 3c, because if
// it isn't, all the other regression tests that use the diagnostic verifier may
// not be able to catch the problems they are supposed to catch. This goes with
// diag_verifier_fail.c.
//
// If 3c correctly exits nonzero when there is an error diagnostic (as tested by
// stdout_mode_write_other.c) and the diagnostic verifier is not active at all,
// then we would expect all the tests with expected errors to actually report
// those errors and fail, so diag_verifier_{pass,fail}.c only add coverage for
// unusual problems with the diagnostic verifier that we haven't seen yet.

// RUN: 3c -base-dir=%S -extra-arg="-Wno-everything" -verify -warn-root-cause %s --

// Example warning borrowed from root_cause.c .
void *x; // expected-warning {{Default void* type}}
8 changes: 8 additions & 0 deletions clang/test/3C/stdout_mode_write_other.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
// writing base_subdir_partial_defn.h is not restricted by the base dir, so we
// reach the stdout mode restriction.

// RUN: rm -rf %t*
// RUN: 3c -base-dir=%S -addcr -verify %s --

// Same as above, except instead of using the diagnostic verifier, manually test
// that 3c exits nonzero and prints the error to stderr. This tests that 3c
// handles diagnostics properly.
//
// RUN: not 3c -base-dir=%S -addcr %s -- 2>%t.stderr
// RUN: grep -q 'error: 3C generated changes to this file, which is under the base dir but is not the main file and thus cannot be written in stdout mode' %t.stderr

// expected-error@base_subdir_partial_defn.h:1 {{3C generated changes to this file, which is under the base dir but is not the main file and thus cannot be written in stdout mode}}
// expected-note@*:* {{-dump-unwritable-changes}}
// expected-note@*:* {{-allow-unwritable-changes}}
Expand Down