diff --git a/tests/data/jsons/sys-prefix.json b/tests/data/jsons/sys-prefix.json index f949319d..f44c1bf0 100644 --- a/tests/data/jsons/sys-prefix.json +++ b/tests/data/jsons/sys-prefix.json @@ -19,16 +19,11 @@ "-c", "import sys; f = open(r'__OUTPUT_FILE__', 'w'); f.write(sys.prefix); f.close()" ], - "description": "Note how __OUTPUT_FILE__ is using raw-strings. Otherwise the backslashes are not properly escaped.", - "working_dir": "%TEMP%/working_dir_test" + "description": "Note how __OUTPUT_FILE__ is using raw-strings. Otherwise the backslashes are not properly escaped." }, - "linux": { - "precommand": "export TMP=/tmp", - "working_dir": "${HOME}/working_dir_test" - }, + "linux": {}, "osx": { - "CFBundleName": "Sys Prefix", - "working_dir": "${TMPDIR}/working_dir_test" + "CFBundleName": "Sys Prefix" } } } diff --git a/tests/data/jsons/working-dir.json b/tests/data/jsons/working-dir.json new file mode 100644 index 00000000..6d68b21c --- /dev/null +++ b/tests/data/jsons/working-dir.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://json-schema.org/draft-07/schema", + "$id": "https://schemas.conda.io/menuinst-1.schema.json", + "menu_name": "Sys.Prefix {{ DISTRIBUTION_NAME }}", + "menu_items": [ + { + "name": "Sys.Prefix", + "description": "This will install to Windows and Linux with default options. MacOS has a custom option.", + "icon": null, + "command": [ + "{{ PYTHON }}", + "-c", + "import sys; print(sys.prefix)" + ], + "platforms": { + "win": { + "command": [ + "{{ PYTHON }}", + "-c", + "import sys; f = open(r'__OUTPUT_FILE__', 'w'); f.write(sys.prefix); f.close()" + ], + "description": "Note how __OUTPUT_FILE__ is using raw-strings. Otherwise the backslashes are not properly escaped.", + "working_dir": "%TEMP%/working_dir_test" + }, + "linux": { + "working_dir": "${TMP}/working_dir_test" + }, + "osx": { + "CFBundleName": "Sys Prefix", + "working_dir": "${TMPDIR}/working_dir_test" + } + } + } + ] +} diff --git a/tests/test_api.py b/tests/test_api.py index 2cacd74e..52573d7d 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -374,15 +374,17 @@ def test_name_dictionary(target_env_is_base): remove(abs_json_path, target_prefix=tmp_target_path, base_prefix=tmp_base_path) -def test_vars_in_working_dir(tmp_path, delete_files): +def test_vars_in_working_dir(tmp_path, monkeypatch, delete_files): if PLATFORM == "win": expected_directory = Path(os.environ["TEMP"], "working_dir_test") elif PLATFORM == "osx": expected_directory = Path(os.environ["TMPDIR"], "working_dir_test") else: + # Linux often does not have an environment variable for the tmp directory + monkeypatch.setenv("TMP", "/tmp") expected_directory = Path("/tmp/working_dir_test") delete_files.append(expected_directory) - datafile = str(DATA / "jsons" / "sys-prefix.json") + datafile = str(DATA / "jsons" / "working-dir.json") try: install(datafile, base_prefix=tmp_path, target_prefix=tmp_path) assert expected_directory.exists()