diff --git a/toolchain/diagnostics/BUILD b/toolchain/diagnostics/BUILD index 9af2df3866b3..cd36ef72dd3b 100644 --- a/toolchain/diagnostics/BUILD +++ b/toolchain/diagnostics/BUILD @@ -33,6 +33,7 @@ cc_library( cc_test( name = "diagnostic_emitter_test", + size = "small", srcs = ["diagnostic_emitter_test.cpp"], deps = [ ":diagnostic_emitter", diff --git a/toolchain/diagnostics/diagnostic_emitter_test.cpp b/toolchain/diagnostics/diagnostic_emitter_test.cpp index 4543b5fce8fb..664d9f7a0bd8 100644 --- a/toolchain/diagnostics/diagnostic_emitter_test.cpp +++ b/toolchain/diagnostics/diagnostic_emitter_test.cpp @@ -11,14 +11,9 @@ #include "llvm/Support/FormatVariadic.h" #include "toolchain/diagnostics/mocks.h" -namespace Carbon { +namespace Carbon::Testing { namespace { -using Testing::DiagnosticAt; -using Testing::DiagnosticLevel; -using Testing::DiagnosticMessage; -using Testing::DiagnosticShortName; - struct FakeDiagnostic { static constexpr llvm::StringLiteral ShortName = "fake-diagnostic"; // TODO: consider ways to put the Message into `format` to allow dynamic @@ -91,4 +86,4 @@ TEST(DiagTest, EmitWarnings) { } } // namespace -} // namespace Carbon +} // namespace Carbon::Testing diff --git a/toolchain/driver/BUILD b/toolchain/driver/BUILD index 782700c095a5..a6b714439680 100644 --- a/toolchain/driver/BUILD +++ b/toolchain/driver/BUILD @@ -22,6 +22,7 @@ cc_library( cc_test( name = "driver_test", + size = "small", srcs = ["driver_test.cpp"], deps = [ ":driver", @@ -34,6 +35,7 @@ cc_test( cc_fuzz_test( name = "driver_fuzzer", + size = "small", srcs = ["driver_fuzzer.cpp"], corpus = glob(["fuzzer_corpus/*"]), deps = [ diff --git a/toolchain/driver/driver_fuzzer.cpp b/toolchain/driver/driver_fuzzer.cpp index 967d5914c4af..012cf946bfef 100644 --- a/toolchain/driver/driver_fuzzer.cpp +++ b/toolchain/driver/driver_fuzzer.cpp @@ -12,7 +12,7 @@ #include "llvm/Support/raw_ostream.h" #include "toolchain/driver/driver.h" -namespace Carbon { +namespace Carbon::Testing { static auto Read(const unsigned char*& data, size_t& size, int& output) -> bool { @@ -79,4 +79,4 @@ extern "C" auto LLVMFuzzerTestOneInput(const unsigned char* data, size_t size) } return 0; } -} // namespace Carbon +} // namespace Carbon::Testing diff --git a/toolchain/driver/driver_test.cpp b/toolchain/driver/driver_test.cpp index 6b7c94d84e82..23323f0b50f7 100644 --- a/toolchain/driver/driver_test.cpp +++ b/toolchain/driver/driver_test.cpp @@ -12,13 +12,12 @@ #include "llvm/Support/SourceMgr.h" #include "toolchain/common/yaml_test_helpers.h" -namespace Carbon { +namespace Carbon::Testing { namespace { using ::testing::ElementsAre; using ::testing::HasSubstr; using ::testing::StrEq; -namespace Yaml = Carbon::Testing::Yaml; /// A raw_ostream that makes it easy to repeatedly check streamed output. class RawTestOstream : public llvm::raw_ostream { @@ -235,4 +234,4 @@ TEST(DriverTest, DumpParseTree) { } } // namespace -} // namespace Carbon +} // namespace Carbon::Testing diff --git a/toolchain/lexer/BUILD b/toolchain/lexer/BUILD index 28ebfaf05a7a..bf49f3a0bdef 100644 --- a/toolchain/lexer/BUILD +++ b/toolchain/lexer/BUILD @@ -19,6 +19,7 @@ cc_library( cc_test( name = "token_kind_test", + size = "small", srcs = ["token_kind_test.cpp"], deps = [ ":token_kind", @@ -58,6 +59,7 @@ cc_library( cc_test( name = "numeric_literal_test", + size = "small", srcs = ["numeric_literal_test.cpp"], deps = [ ":numeric_literal", @@ -71,6 +73,7 @@ cc_test( cc_fuzz_test( name = "numeric_literal_fuzzer", + size = "small", srcs = ["numeric_literal_fuzzer.cpp"], corpus = glob(["fuzzer_corpus/numeric_literal/*"]), deps = [ @@ -95,6 +98,7 @@ cc_library( cc_test( name = "string_literal_test", + size = "small", srcs = ["string_literal_test.cpp"], deps = [ ":string_literal", @@ -108,6 +112,7 @@ cc_test( cc_fuzz_test( name = "string_literal_fuzzer", + size = "small", srcs = ["string_literal_fuzzer.cpp"], corpus = glob(["fuzzer_corpus/string_literal/*"]), deps = [ @@ -148,6 +153,7 @@ cc_library( cc_test( name = "tokenized_buffer_test", + size = "small", srcs = ["tokenized_buffer_test.cpp"], deps = [ ":tokenized_buffer", @@ -162,6 +168,7 @@ cc_test( cc_fuzz_test( name = "tokenized_buffer_fuzzer", + size = "small", srcs = ["tokenized_buffer_fuzzer.cpp"], corpus = glob(["fuzzer_corpus/tokenized_buffer/*"]), deps = [ diff --git a/toolchain/lexer/numeric_literal_fuzzer.cpp b/toolchain/lexer/numeric_literal_fuzzer.cpp index b76445549b12..72edcc851541 100644 --- a/toolchain/lexer/numeric_literal_fuzzer.cpp +++ b/toolchain/lexer/numeric_literal_fuzzer.cpp @@ -10,7 +10,7 @@ #include "toolchain/diagnostics/null_diagnostics.h" #include "toolchain/lexer/numeric_literal.h" -namespace Carbon { +namespace Carbon::Testing { // NOLINTNEXTLINE: Match the documented fuzzer entry point declaration style. extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, @@ -28,4 +28,4 @@ extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, return 0; } -} // namespace Carbon +} // namespace Carbon::Testing diff --git a/toolchain/lexer/numeric_literal_test.cpp b/toolchain/lexer/numeric_literal_test.cpp index 4ac2e1847f64..fcc63a357f1b 100644 --- a/toolchain/lexer/numeric_literal_test.cpp +++ b/toolchain/lexer/numeric_literal_test.cpp @@ -15,7 +15,7 @@ #include "toolchain/diagnostics/diagnostic_emitter.h" #include "toolchain/lexer/test_helpers.h" -namespace Carbon { +namespace Carbon::Testing { namespace { using ::testing::_; @@ -338,4 +338,4 @@ TEST_F(NumericLiteralTest, TooManyDigits) { } } // namespace -} // namespace Carbon +} // namespace Carbon::Testing diff --git a/toolchain/lexer/string_literal_fuzzer.cpp b/toolchain/lexer/string_literal_fuzzer.cpp index 9706861328b6..c0f4cf3c887e 100644 --- a/toolchain/lexer/string_literal_fuzzer.cpp +++ b/toolchain/lexer/string_literal_fuzzer.cpp @@ -10,7 +10,7 @@ #include "toolchain/diagnostics/null_diagnostics.h" #include "toolchain/lexer/string_literal.h" -namespace Carbon { +namespace Carbon::Testing { // NOLINTNEXTLINE: Match the documented fuzzer entry point declaration style. extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, @@ -34,4 +34,4 @@ extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, return 0; } -} // namespace Carbon +} // namespace Carbon::Testing diff --git a/toolchain/lexer/string_literal_test.cpp b/toolchain/lexer/string_literal_test.cpp index 892d5288b789..051dc5b001b6 100644 --- a/toolchain/lexer/string_literal_test.cpp +++ b/toolchain/lexer/string_literal_test.cpp @@ -11,7 +11,7 @@ #include "toolchain/diagnostics/diagnostic_emitter.h" #include "toolchain/lexer/test_helpers.h" -namespace Carbon { +namespace Carbon::Testing { namespace { class StringLiteralTest : public ::testing::Test { @@ -291,4 +291,4 @@ TEST_F(StringLiteralTest, TabInBlockString) { } } // namespace -} // namespace Carbon +} // namespace Carbon::Testing diff --git a/toolchain/lexer/token_kind_test.cpp b/toolchain/lexer/token_kind_test.cpp index 4b8b1a1f6456..c079a0d284cb 100644 --- a/toolchain/lexer/token_kind_test.cpp +++ b/toolchain/lexer/token_kind_test.cpp @@ -11,7 +11,7 @@ #include "llvm/ADT/StringRef.h" -namespace Carbon { +namespace Carbon::Testing { namespace { using ::testing::MatchesRegex; @@ -91,4 +91,4 @@ TEST(TokenKindTest, SymbolsInDescendingLength) { } } // namespace -} // namespace Carbon +} // namespace Carbon::Testing diff --git a/toolchain/lexer/tokenized_buffer_fuzzer.cpp b/toolchain/lexer/tokenized_buffer_fuzzer.cpp index 4927a88c1545..bf3f35d65695 100644 --- a/toolchain/lexer/tokenized_buffer_fuzzer.cpp +++ b/toolchain/lexer/tokenized_buffer_fuzzer.cpp @@ -11,7 +11,7 @@ #include "toolchain/diagnostics/null_diagnostics.h" #include "toolchain/lexer/tokenized_buffer.h" -namespace Carbon { +namespace Carbon::Testing { // NOLINTNEXTLINE: Match the documented fuzzer entry point declaration style. extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, @@ -62,4 +62,4 @@ extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, return 0; } -} // namespace Carbon +} // namespace Carbon::Testing diff --git a/toolchain/lexer/tokenized_buffer_test.cpp b/toolchain/lexer/tokenized_buffer_test.cpp index 3d01b9e38aa0..d0dd64689e54 100644 --- a/toolchain/lexer/tokenized_buffer_test.cpp +++ b/toolchain/lexer/tokenized_buffer_test.cpp @@ -21,18 +21,13 @@ #include "toolchain/diagnostics/mocks.h" #include "toolchain/lexer/tokenized_buffer_test_helpers.h" -namespace Carbon { +namespace Carbon::Testing { namespace { -using ::Carbon::Testing::DiagnosticAt; -using ::Carbon::Testing::DiagnosticMessage; -using ::Carbon::Testing::ExpectedToken; -using ::Carbon::Testing::HasTokens; using ::testing::ElementsAre; using ::testing::Eq; using ::testing::HasSubstr; using ::testing::StrEq; -namespace Yaml = Carbon::Testing::Yaml; class LexerTest : public ::testing::Test { protected: @@ -1103,4 +1098,4 @@ TEST_F(LexerTest, PrintingAsYaml) { } } // namespace -} // namespace Carbon +} // namespace Carbon::Testing diff --git a/toolchain/parser/BUILD b/toolchain/parser/BUILD index efdd8cd52314..ab2ef9e222fe 100644 --- a/toolchain/parser/BUILD +++ b/toolchain/parser/BUILD @@ -16,6 +16,7 @@ cc_library( cc_test( name = "parse_node_kind_test", + size = "small", srcs = ["parse_node_kind_test.cpp"], deps = [ ":parse_node_kind", @@ -58,6 +59,7 @@ cc_library( cc_test( name = "parse_tree_test", + size = "small", srcs = ["parse_tree_test.cpp"], deps = [ ":parse_node_kind", @@ -75,6 +77,7 @@ cc_test( cc_fuzz_test( name = "parse_tree_fuzzer", + size = "small", srcs = ["parse_tree_fuzzer.cpp"], corpus = glob(["fuzzer_corpus/*"]), deps = [ @@ -100,6 +103,7 @@ cc_library( cc_test( name = "precedence_test", + size = "small", srcs = ["precedence_test.cpp"], deps = [ ":precedence", diff --git a/toolchain/parser/parse_node_kind_test.cpp b/toolchain/parser/parse_node_kind_test.cpp index 74ac8a58785e..50a7c0eaf141 100644 --- a/toolchain/parser/parse_node_kind_test.cpp +++ b/toolchain/parser/parse_node_kind_test.cpp @@ -10,8 +10,7 @@ #include "llvm/ADT/StringRef.h" -namespace Carbon { - +namespace Carbon::Testing { namespace { // Not much to test here, so just verify that the API compiles and returns the @@ -23,4 +22,4 @@ namespace { #include "toolchain/parser/parse_node_kind.def" } // namespace -} // namespace Carbon +} // namespace Carbon::Testing diff --git a/toolchain/parser/parse_test_helpers.h b/toolchain/parser/parse_test_helpers.h index e5c7abaec4ee..bccfee8b96c8 100644 --- a/toolchain/parser/parse_test_helpers.h +++ b/toolchain/parser/parse_test_helpers.h @@ -271,9 +271,6 @@ inline auto MatchParseTreeNodes( new ExpectedNodesMatcher(std::move(expected_nodes))); } -// Node matchers. Intended to be brought in by 'using namespace'. -namespace NodeMatchers { - // Matcher argument for a node with errors. struct HasErrorTag {}; inline constexpr HasErrorTag HasError; @@ -341,8 +338,6 @@ auto MatchFunctionWithBody(Args... args) -> ExpectedNode { MatchCodeBlock(std::move(args)..., MatchCodeBlockEnd())); } -} // namespace NodeMatchers - } // namespace Testing } // namespace Carbon diff --git a/toolchain/parser/parse_tree_fuzzer.cpp b/toolchain/parser/parse_tree_fuzzer.cpp index 176873ad0715..a877abeb119b 100644 --- a/toolchain/parser/parse_tree_fuzzer.cpp +++ b/toolchain/parser/parse_tree_fuzzer.cpp @@ -13,7 +13,7 @@ #include "toolchain/lexer/tokenized_buffer.h" #include "toolchain/parser/parse_tree.h" -namespace Carbon { +namespace Carbon::Testing { // NOLINTNEXTLINE: Match the documented fuzzer entry point declaration style. extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, @@ -61,4 +61,4 @@ extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, return 0; } -} // namespace Carbon +} // namespace Carbon::Testing diff --git a/toolchain/parser/parse_tree_test.cpp b/toolchain/parser/parse_tree_test.cpp index 5ebd99c839ae..42b094ca482b 100644 --- a/toolchain/parser/parse_tree_test.cpp +++ b/toolchain/parser/parse_tree_test.cpp @@ -19,18 +19,13 @@ #include "toolchain/parser/parse_node_kind.h" #include "toolchain/parser/parse_test_helpers.h" -namespace Carbon { +namespace Carbon::Testing { namespace { -using Carbon::Testing::DiagnosticMessage; -using Carbon::Testing::ExpectedNode; -using Carbon::Testing::MatchParseTreeNodes; -using namespace Carbon::Testing::NodeMatchers; using ::testing::ElementsAre; using ::testing::Eq; using ::testing::Ne; using ::testing::StrEq; -namespace Yaml = Carbon::Testing::Yaml; class ParseTreeTest : public ::testing::Test { protected: @@ -1176,4 +1171,4 @@ TEST_F(ParseTreeTest, ParenMatchRegression) { } } // namespace -} // namespace Carbon +} // namespace Carbon::Testing diff --git a/toolchain/parser/precedence_test.cpp b/toolchain/parser/precedence_test.cpp index 896a35a6d928..3adb607ca1aa 100644 --- a/toolchain/parser/precedence_test.cpp +++ b/toolchain/parser/precedence_test.cpp @@ -9,7 +9,7 @@ #include "toolchain/lexer/token_kind.h" -namespace Carbon { +namespace Carbon::Testing { namespace { using ::testing::Eq; @@ -154,4 +154,4 @@ TEST(PrecedenceTest, IncomparableOperators) { } } // namespace -} // namespace Carbon +} // namespace Carbon::Testing diff --git a/toolchain/source/BUILD b/toolchain/source/BUILD index 9de485150905..968e1e9465de 100644 --- a/toolchain/source/BUILD +++ b/toolchain/source/BUILD @@ -16,6 +16,7 @@ cc_library( cc_test( name = "source_buffer_test", + size = "small", srcs = ["source_buffer_test.cpp"], deps = [ ":source_buffer", diff --git a/toolchain/source/source_buffer_test.cpp b/toolchain/source/source_buffer_test.cpp index e131c73fb49b..2f05695493b0 100644 --- a/toolchain/source/source_buffer_test.cpp +++ b/toolchain/source/source_buffer_test.cpp @@ -11,7 +11,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/raw_ostream.h" -namespace Carbon { +namespace Carbon::Testing { namespace { TEST(SourceBufferTest, StringRep) { @@ -59,4 +59,4 @@ TEST(SourceBufferTest, FileRep) { } } // namespace -} // namespace Carbon +} // namespace Carbon::Testing