diff --git a/fre/make/fremake.py b/fre/make/fremake.py index 1d5451443..b71e4a33b 100644 --- a/fre/make/fremake.py +++ b/fre/make/fremake.py @@ -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", @@ -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 """ diff --git a/fre/make/run_fremake_script.py b/fre/make/run_fremake_script.py index f17693618..ec506cbc2 100644 --- a/fre/make/run_fremake_script.py +++ b/fre/make/run_fremake_script.py @@ -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 diff --git a/fre/make/tests/test_run_fremake.py b/fre/make/tests/test_run_fremake.py index fa4b8b89a..017fcc9b8 100644 --- a/fre/make/tests/test_run_fremake.py +++ b/fre/make/tests/test_run_fremake.py @@ -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 @@ -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 ''' @@ -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 ''' @@ -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 ''' @@ -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 '''