mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Split up tests for bad imports. (#7612)
Clang treats "file not found" as a fatal error and stops emitting more diagnostics after reaching it, so these tests don't work in `--share-cpp-ast` mode if they are all in the same file. So split them into distinct test files.
This commit is contained in:
@@ -10,48 +10,6 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/basics/import/bad_import.carbon
|
||||
|
||||
// --- fail_import_cpp_library_empty.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_import_cpp_library_empty.carbon:[[@LINE+4]]:10: error: empty filename [CppInteropParseError]
|
||||
// CHECK:STDERR: 8 | #include ""
|
||||
// CHECK:STDERR: | ^
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "";
|
||||
|
||||
// --- fail_import_cpp_library_nonexistent.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_import_cpp_library_nonexistent.carbon:[[@LINE+4]]:10: error: 'does_not_exist.h' file not found [CppInteropParseError]
|
||||
// CHECK:STDERR: 8 | #include "does_not_exist.h"
|
||||
// CHECK:STDERR: | ^~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "does_not_exist.h";
|
||||
|
||||
// --- fail_todo_import_cpp_library_file_with_quotes.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// TODO: Translate the file to a `#include` that includes the named file
|
||||
// properly. `\` escapes aren't processed in regular `#include`s.
|
||||
// CHECK:STDERR: fail_todo_import_cpp_library_file_with_quotes.carbon:[[@LINE+14]]:10: error: '\' file not found [CppInteropParseError]
|
||||
// CHECK:STDERR: 20 | #include "\"foo.h\""
|
||||
// CHECK:STDERR: | ^~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_import_cpp_library_file_with_quotes.carbon:[[@LINE+10]]:13: error: invalid suffix on literal; C++11 requires a space between literal and identifier [CppInteropParseError]
|
||||
// CHECK:STDERR: 20 | #include "\"foo.h\""
|
||||
// CHECK:STDERR: | ^
|
||||
// CHECK:STDERR: | {{}}
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_import_cpp_library_file_with_quotes.carbon:[[@LINE+5]]:13: warning: extra tokens at end of #include directive [CppInteropParseWarning]
|
||||
// CHECK:STDERR: 20 | #include "\"foo.h\""
|
||||
// CHECK:STDERR: | ^
|
||||
// CHECK:STDERR: | //
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "\"foo.h\"";
|
||||
|
||||
// --- fail_unterminated_import_inline.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
|
||||
//
|
||||
// AUTOUPDATE
|
||||
// TIP: To test this file alone, run:
|
||||
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/basics/import/bad_import_empty.carbon
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/basics/import/bad_import_empty.carbon
|
||||
|
||||
// This test must be in a file by itself because it produces a fatal clang error
|
||||
// (file not found), which suppresses all later clang errors in the same
|
||||
// compilation.
|
||||
|
||||
// --- fail_import_cpp_library_empty.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_import_cpp_library_empty.carbon:[[@LINE+4]]:10: error: empty filename [CppInteropParseError]
|
||||
// CHECK:STDERR: 8 | #include ""
|
||||
// CHECK:STDERR: | ^
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "";
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
|
||||
//
|
||||
// AUTOUPDATE
|
||||
// TIP: To test this file alone, run:
|
||||
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/basics/import/bad_import_nested_quotes.carbon
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/basics/import/bad_import_nested_quotes.carbon
|
||||
|
||||
// This test must be in a file by itself because it produces a fatal clang error
|
||||
// (file not found), which suppresses all later clang errors in the same
|
||||
// compilation.
|
||||
|
||||
// --- fail_todo_import_cpp_library_file_with_quotes.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// TODO: Translate the file to a `#include` that includes the named file
|
||||
// properly. `\` escapes aren't processed in regular `#include`s.
|
||||
// CHECK:STDERR: fail_todo_import_cpp_library_file_with_quotes.carbon:[[@LINE+14]]:10: error: '\' file not found [CppInteropParseError]
|
||||
// CHECK:STDERR: 20 | #include "\"foo.h\""
|
||||
// CHECK:STDERR: | ^~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_import_cpp_library_file_with_quotes.carbon:[[@LINE+10]]:13: error: invalid suffix on literal; C++11 requires a space between literal and identifier [CppInteropParseError]
|
||||
// CHECK:STDERR: 20 | #include "\"foo.h\""
|
||||
// CHECK:STDERR: | ^
|
||||
// CHECK:STDERR: | {{}}
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_import_cpp_library_file_with_quotes.carbon:[[@LINE+5]]:13: warning: extra tokens at end of #include directive [CppInteropParseWarning]
|
||||
// CHECK:STDERR: 20 | #include "\"foo.h\""
|
||||
// CHECK:STDERR: | ^
|
||||
// CHECK:STDERR: | //
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "\"foo.h\"";
|
||||
+6
-2
@@ -6,9 +6,13 @@
|
||||
//
|
||||
// AUTOUPDATE
|
||||
// TIP: To test this file alone, run:
|
||||
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/basics/import/file_not_found.carbon
|
||||
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/basics/import/bad_import_not_found.carbon
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/basics/import/file_not_found.carbon
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/basics/import/bad_import_not_found.carbon
|
||||
|
||||
// This test must be in a file by itself because it produces a fatal clang error
|
||||
// (file not found), which suppresses all later clang errors in the same
|
||||
// compilation.
|
||||
|
||||
// --- fail_cpp_file_not_found.carbon
|
||||
|
||||
Reference in New Issue
Block a user