update the integration tests to guess at CMAKE_SOURCE_DIR

Summary:
Our CMakeLists.txt file requests `ctest` to pass in a `CMAKE_SOURCE_DIR`
environment variable when running our integration tests via `ctest`.  However
if a developer manually invokes the test binary this environment variable may
not be set.

For convenience, this updates the code to try looking at the default location
where getdeps will have put the source relative to the build directory (at
least for internal builds using shipit-converted fbsource sources).

Reviewed By: wez

Differential Revision: D21307807

fbshipit-source-id: d747c50d79d2d378721b68b18c256d5363e41f26
This commit is contained in:
Adam Simpkins 2020-04-29 18:48:21 -07:00 committed by Facebook GitHub Bot
parent ea59a68521
commit 0400e99d09

View File

@ -13,6 +13,7 @@ import distutils.spawn
import logging
import os
import sys
from pathlib import Path
from typing import Callable, Dict, Optional, Tuple, Type
import eden.config
@ -288,12 +289,23 @@ class FindExeClass(object):
def _find_cmake_src_dir(self) -> str:
src_dir = os.environ.get("CMAKE_SOURCE_DIR", "")
if not src_dir:
raise Exception(
"unable to find source directory: "
"CMAKE_SOURCE_DIR environment variable is not set"
)
return src_dir
if src_dir:
return src_dir
# The CMAKE_SOURCE_DIR environment variable should always be set if running the
# tests through ctest. However, if the test executable is invoked directly
# CMAKE_SOURCE_DIR may not be set. If this build was driven by getdeps using an
# internal shipit-based build, the sources may exist at ../../shipit/eden.
# Try looking at that location just to make it easier for developers to run the
# test binary manually.
eden_dir = Path.cwd().parent.parent / "shipit" / "eden"
if eden_dir.exists():
return str(eden_dir)
raise Exception(
"unable to find source directory: "
"CMAKE_SOURCE_DIR environment variable is not set"
)
# The main FindExe singleton