From 72c37ff1cb314e071935ab9ef7e5ca91f564cc14 Mon Sep 17 00:00:00 2001 From: jonmeow Date: Wed, 23 Oct 2024 09:47:58 -0700 Subject: [PATCH] Pass the manifest path by flag. --- toolchain/diagnostics/BUILD | 4 +++- toolchain/diagnostics/emitted_diagnostics_test.cpp | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/toolchain/diagnostics/BUILD b/toolchain/diagnostics/BUILD index 068ed0d546b7..53eb05cc61f2 100644 --- a/toolchain/diagnostics/BUILD +++ b/toolchain/diagnostics/BUILD @@ -67,14 +67,16 @@ cc_test( name = "emitted_diagnostics_test", size = "small", srcs = ["emitted_diagnostics_test.cpp"], + args = ["--testdata_manifest=$(location :all_testdata.txt)"], data = [ - "all_testdata.txt", + ":all_testdata.txt", "//toolchain/testing:all_testdata", ], deps = [ ":diagnostic_kind", "//common:set", "//testing/base:gtest_main", + "@abseil-cpp//absl/flags:flag", "@googletest//:gtest", "@llvm-project//llvm:Support", "@re2", diff --git a/toolchain/diagnostics/emitted_diagnostics_test.cpp b/toolchain/diagnostics/emitted_diagnostics_test.cpp index 4f726f0ddd24..022a975bcde2 100644 --- a/toolchain/diagnostics/emitted_diagnostics_test.cpp +++ b/toolchain/diagnostics/emitted_diagnostics_test.cpp @@ -7,11 +7,15 @@ #include #include +#include "absl/flags/flag.h" #include "common/set.h" #include "llvm/ADT/StringExtras.h" #include "re2/re2.h" #include "toolchain/diagnostics/diagnostic_kind.h" +ABSL_FLAG(std::string, testdata_manifest, "", + "A path to a file containing repo-relative names of test files."); + namespace Carbon { namespace { @@ -70,7 +74,7 @@ static auto IsUntestedDiagnostic(DiagnosticKind diagnostic_kind) -> bool { } TEST(EmittedDiagnostics, Verify) { - std::ifstream manifest_in("toolchain/diagnostics/all_testdata.txt"); + std::ifstream manifest_in(absl::GetFlag(FLAGS_testdata_manifest)); ASSERT_TRUE(manifest_in.good()); RE2 diagnostic_re(R"(\w\((\w+)\): )");