From 84fccd71487fe3b81de4e611d12a851d537676eb Mon Sep 17 00:00:00 2001 From: Matt Glazar Date: Fri, 26 Apr 2019 14:08:42 -0700 Subject: [PATCH] Fix code coverage causing test failures Summary: Sandcastle's [1] code coverage builds compile EdenFS and Hg with Clang's -fprofile-generate flag (or a related flag). By default, running a program with with that flag creates a `default.profraw` file in the current directory. This causes some tests to fail, such as HgBackingStoreTest.getTreeForCommit_reimports_tree_if_it_was_deleted_after_import, because `default.profraw` is unintentionally committed to the test repo: ``` [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from HgBackingStoreTest [ RUN ] HgBackingStoreTest.getTreeForCommit_reimports_tree_if_it_was_deleted_after_import eden/fs/store/hg/test/HgBackingStoreTest.cpp:64: Failure Value of: tree1->getEntryNames() Expected: has 2 elements where element #0 is equal to foo, element #1 is equal to src Actual: { default.profraw, foo, src }, which has 3 elements [ FAILED ] HgBackingStoreTest.getTreeForCommit_reimports_tree_if_it_was_deleted_after_import (1563 ms) [----------] 1 test from HgBackingStoreTest (1563 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (1563 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] HgBackingStoreTest.getTreeForCommit_reimports_tree_if_it_was_deleted_after_import ``` When Sandcastle runs the tests, it sets the `LLVM_PROFILE_FILE` environment variable, which configures the path to `default.profraw`. EdenFS' HgRepo class is stripping this variable when invoking hg, so hg uses the default path and not the configured path. Make HgRepo pass `LLVM_PROFILE_FILE` through to hg. This fixes some of EdenFS' tests when run by Sandcastle for code coverage purposes. (This does *not* fix running the tests manually (without setting `LLVM_PROFILE_FILE`), though.) [1] Sandcastle is Facebook's continuous integration system. Reviewed By: simpkins Differential Revision: D15104832 fbshipit-source-id: 3929b9b0ab0904f2552ace7d8e4e4f4a4221192c --- eden/fs/testharness/HgRepo.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eden/fs/testharness/HgRepo.cpp b/eden/fs/testharness/HgRepo.cpp index 6f30cd051f..dd46f361f1 100644 --- a/eden/fs/testharness/HgRepo.cpp +++ b/eden/fs/testharness/HgRepo.cpp @@ -63,7 +63,8 @@ HgRepo::HgRepo(AbsolutePathPiece path) : path_{path} { XLOG(DBG1) << "Using hg command: " << hgCmd_; // Set up hgEnv_ - std::vector passthroughVars{{"PATH", "HG_REAL_BIN"}}; + std::vector passthroughVars{ + {"HG_REAL_BIN", "LLVM_PROFILE_FILE", "PATH"}}; for (const char* varName : passthroughVars) { auto value = getenv(varName); if (value) {