Skip to content

Commit

Permalink
[tests] Fix temporary environment variable setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisCummins committed Feb 22, 2022
1 parent 1e76147 commit f6c1aa1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion compiler_gym/envs/llvm/llvm_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def get_system_library_flags(compiler: Optional[str] = None) -> List[str]:
:raises OSError: If the compiler fails, or if the output of the compiler
cannot be understood.
"""
compiler = compiler or os.environ.get("CXX", "c++")
compiler = compiler or (os.environ.get("CXX") or "c++")
# We want to cache the results of this expensive query, but also emit a
# logging warning when the function is called, including when the call
# results in a cache hit. We therefore must cache both the flags and the
Expand Down
5 changes: 2 additions & 3 deletions tests/llvm/llvm_benchmark_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,14 @@ def test_get_system_library_flags_nonzero_exit_status(caplog):

def test_get_system_library_flags_output_parse_failure(caplog):
"""Test that setting the $CXX to an invalid binary raises an error."""
old_cxx = os.environ.get("CXX")
old_cxx = os.environ.get("CXX", "")
try:
os.environ["CXX"] = "echo"
flags, error = llvm_benchmark._get_cached_system_library_flags("echo")
assert flags == []
assert "Failed to parse '#include <...>' search paths from echo" in error
finally:
if old_cxx:
os.environ["CXX"] = old_cxx
os.environ["CXX"] = old_cxx


def test_get_system_library_flags():
Expand Down

0 comments on commit f6c1aa1

Please sign in to comment.