Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null tests.142 #290

Draft
wants to merge 47 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0e13bee
#142 add basic tests for null
Oct 9, 2024
413f922
rearranged tests and added checkout test
Oct 23, 2024
c7a06ac
testing if runner fixes bug # 142
Oct 24, 2024
2e2dcc3
unfinished update to test path #222
Oct 30, 2024
0ab4be6
test partly working #222
Oct 30, 2024
3b78d84
Merge branch 'main' into null_tests.142
Oct 31, 2024
2fb2724
change to yaml path #222
Oct 31, 2024
2c0846f
improvements to syntax #222
Oct 31, 2024
34eb37e
functional checkout tests #222
Oct 31, 2024
ba1b40b
adjusted path #222
Nov 4, 2024
cfda9af
Merge branch 'main' into null_tests.142
Nov 5, 2024
c295c8b
testing the test
kiihne-noaa Nov 13, 2024
0d28382
Update test_checkout_null_yaml.py
kiihne-noaa Nov 13, 2024
2c41baf
Update test_checkout_null_yaml.py
kiihne-noaa Nov 13, 2024
3f04df9
error review
Dec 16, 2024
70fb326
adjust imports
kiihne-noaa Dec 16, 2024
18def12
Merge pull request #296 from NOAA-GFDL/main
kiihne-noaa Dec 17, 2024
4f51b8b
Update test_checkout_null_yaml.py
kiihne-noaa Dec 17, 2024
77f1bac
trying str paths
kiihne-noaa Dec 18, 2024
f8f3c7b
tests semi working
Dec 18, 2024
fdf6bff
update checkout script print statements
Dec 18, 2024
c7c62d7
Merge branch 'main' into null_tests.142
Jan 8, 2025
cd651df
checkout test working locally
Jan 9, 2025
fe3b347
experimental changes
Jan 14, 2025
69896af
Rename test_basic_null_yaml.py to test_create_checkout.py
kiihne-noaa Jan 14, 2025
da09b07
Update test_checkout_null_yaml.py
kiihne-noaa Jan 14, 2025
f1824e8
Update test_checkout_null_yaml.py
kiihne-noaa Jan 14, 2025
33c1831
add verbose check
kiihne-noaa Jan 16, 2025
1dada88
remove rm statement
kiihne-noaa Jan 16, 2025
91b82b0
Update test_checkout_null_yaml.py
kiihne-noaa Jan 16, 2025
1c3464c
fixing execute
kiihne-noaa Jan 16, 2025
ba54159
Merge branch 'main' into null_tests.142
kiihne-noaa Jan 17, 2025
03bc67a
testing
kiihne-noaa Jan 21, 2025
24d021b
remove rm statement to check error message
kiihne-noaa Jan 21, 2025
baa9293
Update test_checkout_null_yaml.py
kiihne-noaa Jan 22, 2025
320e270
running execute with jobs num designated
kiihne-noaa Jan 27, 2025
3fcd58c
added no parallel checkout test
kiihne-noaa Jan 27, 2025
848ecb2
Update create_checkout_script.py to include new error message
kiihne-noaa Jan 27, 2025
d5ba986
addressing comments
kiihne-noaa Jan 27, 2025
6547d92
undo change to error message
kiihne-noaa Jan 27, 2025
17b609f
adressing various comments
kiihne-noaa Jan 27, 2025
b058aa5
retrying directory
kiihne-noaa Jan 27, 2025
c7c7ec2
Update test_checkout_null_yaml.py
kiihne-noaa Jan 27, 2025
605534e
combine with basic tests
kiihne-noaa Jan 29, 2025
acb276c
Merge pull request #337 from NOAA-GFDL/main
kiihne-noaa Jan 30, 2025
52b69d7
changed error message to check if type(jobs) == bool
kiihne-noaa Feb 5, 2025
ffbdb04
finalizing locations of tests
Feb 5, 2025
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
6 changes: 5 additions & 1 deletion fre/make/create_checkout_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def checkout_create(yamlfile, platform, target, no_parallel_checkout, jobs, exec
run = execute
jobs = str(jobs)
pcheck = no_parallel_checkout


if type(jobs) == bool and execute:
raise ValueError ('jobs must be defined as number if --execute flag is True')
if pcheck:
pc = ""
else:
Expand Down Expand Up @@ -84,7 +86,9 @@ def checkout_create(yamlfile, platform, target, no_parallel_checkout, jobs, exec
if run:
fre_checkout.run()
else:

return

else:
print("\nCheckout script PREVIOUSLY created in "+ src_dir + "/checkout.sh \n")
if run:
Expand Down
83 changes: 83 additions & 0 deletions fre/make/tests/test_create_checkout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#tests for the create-checkout step of fre-make, for null_model.yaml
from pathlib import Path
import os
import subprocess
from fre.make import create_checkout_script

# Set example yaml paths, input directory
TEST_DIR = str(Path("fre/make/tests"))
YAMLFILE = str(Path(f"{TEST_DIR}/null_example/null_model.yaml"))

#set platform and target
PLATFORM = ["ci.gnu"]
TARGET = ["debug"]

#set output directory
# Set home for ~/cylc-src location in script
#run checkout command
OUT = f"{TEST_DIR}/test_run_fremake_multitarget"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sorry, just noticed. I recommend changing OUT to OUT = f"{TEST_DIR}/checkout_out", or something checkout related so we know it's associated with this test. It might be checking for output files in the wrong directory here (that path was from the run-fremake test).

os.environ["TEST_BUILD_DIR"] = OUT

def test_nullyaml_exists():
"""
Make sure combined yaml file exists
"""
assert Path(f"{YAMLFILE}").exists()

def test_nullyaml_filled():
"""
Make sure null.yaml is not an empty file
"""
sum(1 for _ in open(f'{YAMLFILE}')) > 1

def test_checkout_script_exists():
"""
Make sure checkout file exists
"""
subprocess.run(["rm","-rf",f"{OUT}/fremake_canopy/test/null_model_full/src/checkout.sh"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of subprocess.run, let's use shutil.rmtree(OUT) (for directory removal) of Path(.......).unlink (I think it's this) (for file removal) here.

create_checkout_script.checkout_create(YAMLFILE,
PLATFORM,
TARGET,
no_parallel_checkout = False,
jobs = False, execute = False,
verbose = False)
#assert result.exit_code == 0
assert Path(f"{OUT}/fremake_canopy/test/null_model_full/src/checkout.sh").exists()

def test_checkout_verbose():
"""
check if --verbose option works
"""
create_checkout_script.checkout_create(YAMLFILE,
PLATFORM,
TARGET,
no_parallel_checkout = False,
jobs = False,
execute = False,
verbose = True)

def test_checkout_execute():
"""
check if --execute option works
"""
subprocess.run(["rm","-rf",f"{OUT}/fremake_canopy/test"])
create_checkout_script.checkout_create(YAMLFILE,
PLATFORM,
TARGET,
no_parallel_checkout = False,
jobs = 2,
execute = True,
verbose = False)

def test_checkout_no_parallel_checkout():
"""
check if --no_parallel_checkout option works
"""
create_checkout_script.checkout_create(YAMLFILE,
PLATFORM,
TARGET,
no_parallel_checkout = True,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll need to check that actual contents of the file here and add an assert here as well (for file creation).

If the no_parallel option is defined, the checkout script is going to be different. Maybe we can add a pytest skip here and work on updating this test in the next PR.

jobs = False,
execute = False,
verbose = False)