Add new testcase for --regex=ecmascript

The default for --regex is llvm, so it's covered by any existing tests
with mappings.
This commit is contained in:
Kim Gräsman 2022-09-02 21:55:54 +02:00
parent cf53880822
commit 5b5dd13746
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,42 @@
//===--- mapping_regex.cc - test input file for iwyu ----------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I . \
// -Xiwyu --regex=ecmascript \
// -Xiwyu --mapping_file=tests/cxx/mapping_regex.imp
// This test is a little forced, but here's the idea:
// * The include of tests/cxx/direct.h should nominally be replaced by
// tests/cxx/indirect.h, where IndirectClass is defined
// * But we provide a mapping file with a negative lookahead assertion mapping
// any indirect.h **except in not-tests/not-cxx** to foobar.h
// * Since tests/cxx/indirect.h does not match not-tests/not-cxx/indirect.h,
// the mapping will apply...
// * ... but only since the --regex=ecmascript, which is the only dialect
// supporting negative lookahead.
#include "tests/cxx/direct.h"
void f() {
// IWYU: IndirectClass is defined in...*foobar.h
IndirectClass i;
}
/**** IWYU_SUMMARY
tests/cxx/mapping_regex.cc should add these lines:
#include "foobar.h"
tests/cxx/mapping_regex.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/mapping_regex.cc:
#include "foobar.h" // for IndirectClass
***** IWYU_SUMMARY */

View File

@ -0,0 +1,5 @@
# Bogus header mapping using a negative lookahead regex.
# The foobar.h header does not exist; we just want IWYU to suggest using it.
[
{ include: ["@\"(?!.*not-tests/not-cxx/).*indirect.h\"", private, "\"foobar.h\"", public ] },
]