Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions fre/make/fremake.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def make_cli():
The default behavior is to generate the scripts, but not execute.""")
@click.option("--force-checkout",
is_flag = True,
default = False,
help = "Force a git checkout if the source directory already exists.")
@click.option("-v",
"--verbose",
Expand Down Expand Up @@ -156,6 +157,7 @@ def all(yamlfile, platform, target, nparallel, makejobs, gitjobs, no_parallel_ch
The default behavior is to generate the script, but not execute.""")
@click.option("--force-checkout",
is_flag = True,
default = False,
help = "Force a git checkout if the source directory already exists.")
def checkout_script(yamlfile, platform, target, no_parallel_checkout, gitjobs, execute, force_checkout):
""" - Write the checkout script """
Expand Down
4 changes: 2 additions & 2 deletions fre/make/run_fremake_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def fremake_run(yamlfile:str, platform:str, target:str,
no_parallel_checkout: Optional[bool] = None,
no_format_transfer: Optional[bool] = False,
execute: Optional[bool] = False,
force_checkout: Optional[bool] = False,
verbose: Optional[bool] = None):
verbose: Optional[bool] = None,
force_checkout: Optional[bool] = False):
"""
Runs all of fre make code

Expand Down
42 changes: 35 additions & 7 deletions fre/make/tests/test_run_fremake.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,24 @@ def test_bad_platform_option():
''' test run-fremake with a invalid platform option'''
run_fremake_script.fremake_run(YAMLPATH, BADOPT, TARGET,
nparallel=False, makejobs=1, gitjobs=1, no_parallel_checkout=False,
no_format_transfer=False, execute=False, verbose=VERBOSE)
no_format_transfer=False, execute=False, verbose=VERBOSE,
force_checkout=False)

@pytest.mark.xfail()
def test_bad_target_option():
''' test run-fremake with a invalid target option'''
run_fremake_script.fremake_run(YAMLPATH, PLATFORM, BADOPT,
nparallel=False, makejobs=1, gitjobs=1, no_parallel_checkout=False,
no_format_transfer=False, execute=False, verbose=VERBOSE)
no_format_transfer=False, execute=False, verbose=VERBOSE,
force_checkout=False)

@pytest.mark.xfail()
def test_bad_yamlpath_option():
''' test run-fremake with a invalid target option'''
run_fremake_script.fremake_run(BADOPT[0], PLATFORM, TARGET,
nparallel=False, makejobs=1, gitjobs=1, no_parallel_checkout=False,
no_format_transfer=False, execute=False, verbose=VERBOSE)
no_format_transfer=False, execute=False, verbose=VERBOSE,
force_checkout=False)

# tests script/makefile creation without executing (serial compile)
# first test runs the run-fremake command, subsequent tests check for creation of scripts
Expand All @@ -79,7 +82,8 @@ def test_run_fremake_serial():
os.environ["TEST_BUILD_DIR"] = SERIAL_TEST_PATH
run_fremake_script.fremake_run(YAMLPATH, PLATFORM, TARGET,
nparallel=False, makejobs=1, gitjobs=1, no_parallel_checkout=False,
no_format_transfer=False, execute=False, verbose=VERBOSE)
no_format_transfer=False, execute=False, verbose=VERBOSE,
force_checkout=False)

def test_run_fremake_compile_script_creation_serial():
''' check for compile script creation from previous test '''
Expand All @@ -96,13 +100,35 @@ def test_run_fremake_makefile_creation_serial():
assert Path(
f"{SERIAL_TEST_PATH}/fremake_canopy/test/{EXPERIMENT}/{PLATFORM[0]}-{TARGET[0]}/exec/Makefile").exists()

def test_run_fremake_force_checkout_serial(caplog):
''' run fre make with run-fremake subcommand and build the null model experiment with gnu'''
os.environ["TEST_BUILD_DIR"] = SERIAL_TEST_PATH

# double check checkout script exists already
assert Path(
f"{SERIAL_TEST_PATH}/fremake_canopy/test/{EXPERIMENT}/src/checkout.sh").exists()

# run fre make checkout-script with force-checkout
run_fremake_script.fremake_run(YAMLPATH, PLATFORM, TARGET,
nparallel=True, makejobs=4, gitjobs=4, no_parallel_checkout=True,
no_format_transfer=False, execute=False, verbose=VERBOSE,
force_checkout=True)

# Check it exists, check output, check content
assert all(["Checkout script PREVIOUSLY created" in caplog.text,
"*** REMOVING CHECKOUT SCRIPT ***" in caplog.text,
"Checkout script created" in caplog.text,
Path(f"{SERIAL_TEST_PATH}/fremake_canopy/test/{EXPERIMENT}/src/checkout.sh").exists()])

# same tests with multijob compile and non-parallel-checkout options enabled
def test_run_fremake_multijob():
''' run fre make with run-fremake subcommand and build the null model experiment with gnu'''
os.environ["TEST_BUILD_DIR"] = MULTIJOB_TEST_PATH

run_fremake_script.fremake_run(YAMLPATH, PLATFORM, TARGET,
nparallel=True, makejobs=4, gitjobs=4, no_parallel_checkout=True,
no_format_transfer=False, execute=False, verbose=VERBOSE)
no_format_transfer=False, execute=False, verbose=VERBOSE,
force_checkout=False)

def test_run_fremake_compile_script_creation_multijob():
''' check for compile script creation from previous test '''
Expand All @@ -124,7 +150,8 @@ def test_run_fremake_container():
'''run run-fremake with options for containerized build'''
run_fremake_script.fremake_run(YAMLPATH, CONTAINER_PLATFORM, TARGET,
nparallel=False, makejobs=1, gitjobs=1, no_parallel_checkout=True,
no_format_transfer=False, execute=False, verbose=VERBOSE)
no_format_transfer=False, execute=False, verbose=VERBOSE,
force_checkout=False)

def test_run_fremake_build_script_creation_container():
''' checks container build script creation from previous test '''
Expand All @@ -151,7 +178,8 @@ def test_run_fremake_container_2stage():
'''run run-fremake with options for containerized build'''
run_fremake_script.fremake_run(YAMLPATH, CONTAINER_PLAT2, TARGET,
nparallel=False, makejobs=1, gitjobs=1, no_parallel_checkout=True,
no_format_transfer=False, execute=False, verbose=VERBOSE)
no_format_transfer=False, execute=False, verbose=VERBOSE,
force_checkout=False)

def test_run_fremake_build_script_creation_container_2stage():
''' checks container build script creation from previous test '''
Expand Down
Loading