diff options
| author | Fangrui Song <maskray@google.com> | 2019-04-03 07:25:04 +0000 |
|---|---|---|
| committer | Fangrui Song <maskray@google.com> | 2019-04-03 07:25:04 +0000 |
| commit | 2374bff376c6cf54fbea55c739a30968663a5cf1 (patch) | |
| tree | 7eec6e224290a99f85ba08da8cc651e2cbd3222a /clang/bindings/python | |
| parent | d9c24dca73d13d06f2a2ef8cd3abf50fcda14e4e (diff) | |
| download | bcm5719-llvm-2374bff376c6cf54fbea55c739a30968663a5cf1.tar.gz bcm5719-llvm-2374bff376c6cf54fbea55c739a30968663a5cf1.zip | |
[libclang][test] Suppress annoying 'LIBCLANG TOOLING ERROR' output
check-all invokes check-clang-python which prints the annoying message:
LIBCLANG TOOLING ERROR: fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory
Let's fix it now with os.dup os.dup2 trick.
llvm-svn: 357562
Diffstat (limited to 'clang/bindings/python')
| -rw-r--r-- | clang/bindings/python/tests/cindex/test_cdb.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/bindings/python/tests/cindex/test_cdb.py b/clang/bindings/python/tests/cindex/test_cdb.py index 589fc72856b..e2a48f14cde 100644 --- a/clang/bindings/python/tests/cindex/test_cdb.py +++ b/clang/bindings/python/tests/cindex/test_cdb.py @@ -23,8 +23,17 @@ class TestCDB(unittest.TestCase): def test_create_fail(self): """Check we fail loading a database with an assertion""" path = os.path.dirname(__file__) + + # clang_CompilationDatabase_fromDirectory calls fprintf(stderr, ...) + # Suppress its output. + stderr = os.dup(2) + with open(os.devnull, 'wb') as null: + os.dup2(null.fileno(), 2) with self.assertRaises(CompilationDatabaseError) as cm: cdb = CompilationDatabase.fromDirectory(path) + os.dup2(stderr, 2) + os.close(stderr) + e = cm.exception self.assertEqual(e.cdb_error, CompilationDatabaseError.ERROR_CANNOTLOADDATABASE) |

