update fre.make tests to avoid getcwd, and light pylint cleanup#808
update fre.make tests to avoid getcwd, and light pylint cleanup#808
fre.make tests to avoid getcwd, and light pylint cleanup#808Conversation
…e/tests - Fix test_checkout_execute: use no_parallel_checkout=True to avoid shell-backgrounding race conditions (parallel syntax is already tested by test_checkout_script_exists) - Break monolithic assert all([...]) into individual assertions with descriptive messages for better failure diagnostics - Create conftest.py with shared fixtures for TEST_BUILD_DIR and output directory cleanup - Replace bare os.environ with monkeypatch.setenv() across all make tests for proper environment variable isolation between tests - Move module-level side effects (directory creation, shutil.rmtree) into pytest fixtures in test_create_compile.py, test_create_makefile.py, and test_run_fremake.py - Remove unused imports (os from test_create_compile.py, shutil.rmtree from test_run_fremake.py) Agent-Logs-Url: https://github.com/NOAA-GFDL/fre-cli/sessions/ced8734b-77f0-49eb-b4aa-0a029397548c Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
Agent-Logs-Url: https://github.com/NOAA-GFDL/fre-cli/sessions/ced8734b-77f0-49eb-b4aa-0a029397548c Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
|
@copilot try again |
…r all files The test created files with different datetimes (19900101 and 19900201). make_simple_varlist uses iglob to pick one file, extracts its datetime, then globs for all files matching that datetime. When iglob picked the 19900201 file first, the pattern *19900201*.nc only matched that one file, missing the salt file - causing intermittent assertion failures. Fix: use the same datetime (19900101) for the duplicate temp file so the glob pattern matches all files regardless of iglob ordering. Agent-Logs-Url: https://github.com/NOAA-GFDL/fre-cli/sessions/67d662d6-4df4-4e44-8e4e-cc6525f140ed Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
Fixed in 8258e69. The CI failure was in |
|
oh, right... 🙃 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #808 +/- ##
=======================================
Coverage 84.12% 84.12%
=======================================
Files 71 71
Lines 4944 4944
=======================================
Hits 4159 4159
Misses 785 785
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
…etime for all files" This reverts commit 8258e69. The failure was fixed in a different PR, better
#738) All test files in fre/make/tests/ now use Path(__file__).resolve().parent instead of os.getcwd() or hardcoded "fre/make/tests/..." strings. This ensures tests work correctly when pytest is run from any directory, not just the repository root. Files changed: - conftest.py, test_create_checkout.py, test_create_compile.py, test_create_makefile.py: Path("fre/make/tests") → Path(__file__).resolve().parent - test_create_dockerfile.py: YAMLDIR uses __file__-relative path; removed os.getcwd() - test_run_fremake.py: all paths use __file__-relative; os.environ → monkeypatch; removed os.getcwd() and unused import os - compilation/test_run_fremake_builds.py: currPath=os.getcwd() → _TEST_DIR = Path(__file__).resolve().parent Note: container output paths (tmp/, createContainer.sh, Dockerfile) remain CWD-relative since the production code creates them in CWD by design. Agent-Logs-Url: https://github.com/NOAA-GFDL/fre-cli/sessions/93d0cce5-40bc-46a1-89c8-ada3eed3265a Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
Addressed in b5de105. All test files in Container output paths ( |
… PATH search subprocess.run() with a bare filename (no directory separator) searches $PATH instead of looking in CWD. The original code used an absolute path via os.getcwd() which had a directory component. After switching to relative paths for #738, we need './' prefix so subprocess finds the CWD file directly. Agent-Logs-Url: https://github.com/NOAA-GFDL/fre-cli/sessions/2adfb38f-005c-4d4f-84ce-d74925588f9d Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
notable caveat |
Path("./createContainer.sh") normalizes to PosixPath("createContainer.sh"),
stripping the "./" directory separator. Without it, subprocess.run searches
$PATH instead of looking in the current working directory, causing
FileNotFoundError in CI.
Agent-Logs-Url: https://github.com/NOAA-GFDL/fre-cli/sessions/3cf04c93-09b4-45a1-ae96-d20489b8c309
Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
Agent-Logs-Url: https://github.com/NOAA-GFDL/fre-cli/sessions/3cf04c93-09b4-45a1-ae96-d20489b8c309 Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
…json files) Agent-Logs-Url: https://github.com/NOAA-GFDL/fre-cli/sessions/3cf04c93-09b4-45a1-ae96-d20489b8c309 Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
…ecks via with pytest.raises(...)
fre.make tests to avoid getcwd, and light pylint cleanup
Describe your changes
test_run_fremake_container_build_failfails in CI across all Python versions with:Root cause:
Path("./createContainer.sh")normalizes toPosixPath('createContainer.sh'), stripping the./directory separator. Without it,subprocess.runsearches$PATHinstead of CWD.This was introduced by the earlier commit converting
os.getcwd()-based absolute paths to relative paths for #738. The original code usedf"{currPath}/createContainer.sh"which always had a directory component.Issue ticket number and link (if applicable)
Checklist before requesting a review
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.