diff --git a/examples/from_env_yaml/env.yaml b/examples/from_env_yaml/env.yaml index e9f2ae62e..fc6253531 100644 --- a/examples/from_env_yaml/env.yaml +++ b/examples/from_env_yaml/env.yaml @@ -2,5 +2,5 @@ name: testenv channels: - defaults dependencies: - - python - - conda + - python=3.9 + - conda=23.3 diff --git a/tests/test_examples.py b/tests/test_examples.py index d8c10802e..4bd862a39 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -36,7 +36,7 @@ def _execute( - cmd: Iterable[str], installer_input=None, check=True, **env_vars + cmd: Iterable[str], installer_input=None, check=True, timeout=420, **env_vars ) -> subprocess.CompletedProcess: t0 = time.time() if env_vars: @@ -54,7 +54,7 @@ def _execute( ) stdout, stderr = None, None try: - stdout, stderr = p.communicate(input=installer_input, timeout=420) + stdout, stderr = p.communicate(input=installer_input, timeout=timeout) retcode = p.poll() if check and retcode: raise subprocess.CalledProcessError(retcode, cmd, output=stdout, stderr=stderr) @@ -71,7 +71,7 @@ def _execute( print("Took", timedelta(seconds=time.time() - t0)) -def _run_installer_exe(installer, install_dir, installer_input=None): +def _run_installer_exe(installer, install_dir, installer_input=None, timeout=420): """ NSIS manual: > /D sets the default installation directory ($INSTDIR), overriding InstallDir @@ -94,7 +94,7 @@ def _run_installer_exe(installer, install_dir, installer_input=None): "after completion." ) cmd = ["cmd.exe", "/c", "start", "/wait", installer, "/S", *f"/D={install_dir}".split()] - _execute(cmd) + _execute(cmd, installer_input=installer_input, timeout=timeout) # Windows installers won't raise exit codes so we need to check the log file error_lines = [] @@ -118,7 +118,7 @@ def _run_installer_exe(installer, install_dir, installer_input=None): raise AssertionError("\n".join(error_lines)) -def _run_uninstaller_exe(install_dir): +def _run_uninstaller_exe(install_dir, timeout=420): # Now test the uninstallers if " " in str(install_dir): # TODO: We can't seem to run the uninstaller when there are spaces in the PATH @@ -143,7 +143,7 @@ def _run_uninstaller_exe(install_dir): # us problems with the tempdir cleanup later f"/S _?={install_dir}", ] - _execute(cmd) + _execute(cmd, timeout=timeout) remaining_files = list(install_dir.iterdir()) if len(remaining_files) > 2: # The debug installer writes to install.log too, which will only @@ -155,15 +155,15 @@ def _run_uninstaller_exe(install_dir): raise AssertionError(f"Uninstaller left too many files: {remaining_files}") -def _run_installer_sh(installer, install_dir, installer_input=None): +def _run_installer_sh(installer, install_dir, installer_input=None, timeout=420): if installer_input: cmd = ["/bin/sh", installer] else: cmd = ["/bin/sh", installer, "-b", "-p", install_dir] - return _execute(cmd, installer_input=installer_input) + return _execute(cmd, installer_input=installer_input, timeout=timeout) -def _run_installer_pkg(installer, install_dir, example_path=None): +def _run_installer_pkg(installer, install_dir, example_path=None, timeout=420): if os.environ.get("CI"): # We want to run it in an arbitrary directory, but the options # are limited here... We can only install to $HOME :shrug: @@ -186,7 +186,7 @@ def _run_installer_pkg(installer, install_dir, example_path=None): "Export CI=1 to run it, but it will pollute your $HOME." ) cmd = ["pkgutil", "--expand", installer, install_dir] - return _execute(cmd), install_dir + return _execute(cmd, timeout=timeout), install_dir def _sentinel_file_checks(example_path, install_dir): @@ -208,21 +208,22 @@ def _run_installer( installer_input: Optional[str] = None, check_sentinels=True, request=None, + timeout=420, ): if installer.suffix == ".exe": - _run_installer_exe(installer, install_dir, installer_input=installer_input) + _run_installer_exe(installer, install_dir, installer_input=installer_input, timeout=timeout) elif installer.suffix == ".sh": - _run_installer_sh(installer, install_dir, installer_input=installer_input) + _run_installer_sh(installer, install_dir, installer_input=installer_input, timeout=timeout) elif installer.suffix == ".pkg": if request and ON_CI: request.addfinalizer(lambda: shutil.rmtree(str(install_dir))) - _run_installer_pkg(installer, install_dir, example_path=example_path) + _run_installer_pkg(installer, install_dir, example_path=example_path, timeout=timeout) else: raise ValueError(f"Unknown installer type: {installer.suffix}") if check_sentinels: _sentinel_file_checks(example_path, install_dir) if installer.suffix == ".exe": - _run_uninstaller_exe(install_dir) + _run_uninstaller_exe(install_dir, timeout=timeout) def create_installer( @@ -231,6 +232,7 @@ def create_installer( conda_exe=CONSTRUCTOR_CONDA_EXE, debug=CONSTRUCTOR_DEBUG, with_spaces=False, + timeout=420, **env_vars, ) -> Tuple[Path, Path]: if sys.platform.startswith("win") and conda_exe and _is_micromamba(conda_exe): @@ -251,7 +253,7 @@ def create_installer( if debug: cmd.append("--debug") - _execute(cmd, **env_vars) + _execute(cmd, timeout=timeout, **env_vars) install_dir_prefix = "i n s t a l l" if with_spaces else "install" @@ -421,7 +423,7 @@ def test_example_from_env_txt(tmp_path, request): def test_example_from_env_yaml(tmp_path, request): input_path = _example_path("from_env_yaml") - for installer, install_dir in create_installer(input_path, tmp_path): + for installer, install_dir in create_installer(input_path, tmp_path, timeout=600): _run_installer(input_path, installer, install_dir, request=request) if installer.suffix == ".pkg" and not ON_CI: return