Skip to content

Commit

Permalink
TEST: Similer --fast as LFortran for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaikh-Ubaid committed Jun 27, 2023
1 parent 9aa4f99 commit 3fdcac3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 6 additions & 4 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR
endif ()

set(KIND no CACHE STRING "Type of Test")
set(DISABLE_FAST no CACHE BOOL "Disable --fast testing of integration tests")
set(FAST no CACHE BOOL "Run supported tests with --fast")

find_program(LPYTHON NAMES lpython)

Expand Down Expand Up @@ -69,7 +69,7 @@ else ()
endif ()
message("Installation prefix: ${CMAKE_INSTALL_PREFIX}")
message("KIND: ${KIND}")
message("DISABLE_FAST: ${DISABLE_FAST}")
message("FAST: ${FAST}")
message("PYTHON_LIBS_REQ: ${PYTHON_LIBS_REQ}")
message("LPYTHON: ${LPYTHON}")
message("LPYTHON_RTLIB_DIR: ${LPYTHON_RTLIB_DIR}")
Expand Down Expand Up @@ -287,9 +287,11 @@ macro(RUN)
set(RUN_EXTRA_ARGS ${RUN_EXTRA_ARGS} -I${CMAKE_CURRENT_SOURCE_DIR}/${RUN_IMPORT_PATH})
endif()

RUN_UTIL(RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS)
if (NOT FAST)
RUN_UTIL(RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS)
endif()

if ((NOT DISABLE_FAST) AND (NOT RUN_NOFAST))
if ((FAST) AND (NOT RUN_NOFAST))
set(RUN_EXTRA_ARGS ${RUN_EXTRA_ARGS} --fast)
set(RUN_NAME "${RUN_NAME}_FAST")
list(REMOVE_ITEM RUN_LABELS cpython cpython_sym) # remove cpython, cpython_sym, from --fast test
Expand Down
12 changes: 6 additions & 6 deletions integration_tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
LPYTHON_PATH = f"{BASE_DIR}/../src/bin"

disable_fast = "no"
fast_tests = "no"
python_libs_req = "no"

def run_cmd(cmd, cwd=None):
Expand All @@ -24,7 +24,7 @@ def run_cmd(cmd, cwd=None):
def run_test(backend):
run_cmd(f"mkdir {BASE_DIR}/_lpython-tmp-test-{backend}", cwd=BASE_DIR)
cwd = f"{BASE_DIR}/_lpython-tmp-test-{backend}"
run_cmd(f"cmake -DKIND={backend} -DDISABLE_FAST={disable_fast} -DPYTHON_LIBS_REQ={python_libs_req} ..", cwd=cwd)
run_cmd(f"cmake -DKIND={backend} -DFAST={fast_tests} -DPYTHON_LIBS_REQ={python_libs_req} ..", cwd=cwd)
run_cmd(f"make -j{DEFAULT_THREADS_TO_USE}", cwd=cwd)
run_cmd(f"ctest -j{DEFAULT_THREADS_TO_USE} --output-on-failure",
cwd=cwd)
Expand All @@ -44,23 +44,23 @@ def get_args():
parser.add_argument("-b", "--backends", nargs="*", default=["llvm", "cpython"],
type=str, help="Test the requested backends (%s), default: llvm, cpython" % \
", ".join(SUPPORTED_BACKENDS))
parser.add_argument("-nf", "--no_fast", action='store_true',
help="Disable --fast testing of integration tests")
parser.add_argument("-f", "--fast", action='store_true',
help="Run supported tests with --fast")
return parser.parse_args()


def main():
args = get_args()

# Setup
global DEFAULT_THREADS_TO_USE, disable_fast, python_libs_req
global DEFAULT_THREADS_TO_USE, fast_tests, python_libs_req
os.environ["PATH"] = LPYTHON_PATH + os.pathsep + os.environ["PATH"]
# delete previously created directories (if any)
for backend in SUPPORTED_BACKENDS:
run_cmd(f"rm -rf {BASE_DIR}/_lpython-tmp-test-{backend}")

DEFAULT_THREADS_TO_USE = args.no_of_threads or DEFAULT_THREADS_TO_USE
disable_fast = "yes" if args.no_fast else "no"
fast_tests = "yes" if args.fast else "no"
for backend in args.backends:
python_libs_req = "yes" if backend in ["c_py", "c_sym"] else "no"
test_backend(backend)
Expand Down

0 comments on commit 3fdcac3

Please sign in to comment.