mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Added GetRunfilesFile() to be able to reliably determine prelude location under various invocation scenarios
The logic is using bazel Runfiles API per Jon's suggestion. One of the scenarios used by the fuzzing framework is to place the binary and its runfiles into a folder, resulting in a directory layout like this: [temp dir] fuzzer fuzzer.runfiles/ Tested: bazel test -c opt explorer/fuzzing:explorer_fuzzer bazel build -c opt explorer/fuzzing:explorer_fuzzer + run the binary from various locations
This commit is contained in:
@@ -36,6 +36,19 @@ TEST(FuzzerUtilTest, RunFuzzerOnCorpus) {
|
||||
EXPECT_GT(file_count, 0);
|
||||
}
|
||||
|
||||
TEST(FuzzerUtilTest, GetRunfilesFile) {
|
||||
EXPECT_THAT(*Internal::GetRunfilesFile(
|
||||
"carbon/explorer/fuzzing/fuzzer_corpus/empty.textproto"),
|
||||
testing::EndsWith("/explorer/fuzzing/fuzzer_corpus/"
|
||||
"empty.textproto"));
|
||||
EXPECT_THAT(Internal::GetRunfilesFile(
|
||||
"explorer/fuzzing/fuzzer_corpus/empty.textproto")
|
||||
.error()
|
||||
.message(),
|
||||
testing::EndsWith("fuzzer_util_test.runfiles/explorer/fuzzing/"
|
||||
"fuzzer_corpus/empty.textproto doesn't exist"));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace Carbon::Testing
|
||||
|
||||
|
||||
Reference in New Issue
Block a user