From a0ac6a92125cf6e2fb89daf92be293b28d497c38 Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Fri, 11 Feb 2022 10:42:38 -0800 Subject: [PATCH] [RGT] Refactor Windows-specific checks into their own test This allows using GTEST_SKIP() to identify un-executed tests. Found by the Rotten Green Tests project. --- llvm/unittests/Support/CommandLineTest.cpp | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp index 2e007bfff187..9a7f4f38740f 100644 --- a/llvm/unittests/Support/CommandLineTest.cpp +++ b/llvm/unittests/Support/CommandLineTest.cpp @@ -743,21 +743,24 @@ TEST(CommandLineTest, ArgumentLimit) { EXPECT_FALSE(llvm::sys::commandLineFitsWithinSystemLimits("cl", args.data())); std::string args2(256, 'a'); EXPECT_TRUE(llvm::sys::commandLineFitsWithinSystemLimits("cl", args2.data())); - if (Triple(sys::getProcessTriple()).isOSWindows()) { - // We use 32000 as a limit for command line length. Program name ('cl'), - // separating spaces and termination null character occupy 5 symbols. - std::string long_arg(32000 - 5, 'b'); - EXPECT_TRUE( - llvm::sys::commandLineFitsWithinSystemLimits("cl", long_arg.data())); - long_arg += 'b'; - EXPECT_FALSE( - llvm::sys::commandLineFitsWithinSystemLimits("cl", long_arg.data())); - } +} + +TEST(CommandLineTest, ArgumentLimitWindows) { + if (!Triple(sys::getProcessTriple()).isOSWindows()) + GTEST_SKIP(); + // We use 32000 as a limit for command line length. Program name ('cl'), + // separating spaces and termination null character occupy 5 symbols. + std::string long_arg(32000 - 5, 'b'); + EXPECT_TRUE( + llvm::sys::commandLineFitsWithinSystemLimits("cl", long_arg.data())); + long_arg += 'b'; + EXPECT_FALSE( + llvm::sys::commandLineFitsWithinSystemLimits("cl", long_arg.data())); } TEST(CommandLineTest, ResponseFileWindows) { if (!Triple(sys::getProcessTriple()).isOSWindows()) - return; + GTEST_SKIP(); StackOption> InputFilenames( cl::Positional, cl::desc(""), cl::ZeroOrMore);