diff --git a/src/wxflow/configuration.py b/src/wxflow/configuration.py index 77cf009..e9d0cb3 100644 --- a/src/wxflow/configuration.py +++ b/src/wxflow/configuration.py @@ -1,6 +1,8 @@ import glob import os +import re import random +import shutil import subprocess from pathlib import Path from pprint import pprint @@ -94,12 +96,14 @@ def print_config(self, files: Union[str, bytes, list]) -> None: @classmethod def _get_script_env(cls, scripts: List) -> Dict[str, Any]: + varbles = dict() default_env = cls._get_shell_env([]) and_script_env = cls._get_shell_env(scripts) - vars_just_in_script = set(and_script_env) - set(default_env) - union_env = dict(default_env) - union_env.update(and_script_env) - return dict([(v, union_env[v]) for v in vars_just_in_script]) + + for key, value in and_script_env.items(): + if key not in default_env or default_env[key] != value: + varbles[key] = value + return varbles @staticmethod def _get_shell_env(scripts: List) -> Dict[str, Any]: @@ -107,8 +111,9 @@ def _get_shell_env(scripts: List) -> Dict[str, Any]: runme = ''.join([f'source {s} ; ' for s in scripts]) magic = f'--- ENVIRONMENT BEGIN {random.randint(0,64**5)} ---' runme += f'/bin/echo -n "{magic}" ; /usr/bin/env -0' + bash_path = shutil.which('bash') with open('/dev/null', 'w') as null: - env = subprocess.Popen(runme, shell=True, stdin=null.fileno(), + env = subprocess.Popen(runme, shell=True, executable=bash_path, stdin=null.fileno(), stdout=subprocess.PIPE) (out, err) = env.communicate() out = out.decode() diff --git a/tests/test_configuration.py b/tests/test_configuration.py index 80ed966..fefc4f9 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -144,7 +144,6 @@ def test_configuration_config_dir(tmp_path, create_configs): assert cfg.config_dir == tmp_path -@pytest.mark.skip(reason="fails in GH runner, passes on localhost") def test_configuration_config_files(tmp_path, create_configs): cfg = Configuration(tmp_path) config_files = [str(tmp_path / 'config.file0'), str(tmp_path / 'config.file1')] @@ -157,14 +156,12 @@ def test_find_config(tmp_path, create_configs): assert str(tmp_path / 'config.file0') == file0 -@pytest.mark.skip(reason="fails in GH runner, passes on localhost") def test_parse_config1(tmp_path, create_configs): cfg = Configuration(tmp_path) f0 = cfg.parse_config('config.file0') assert file0_dict == f0 -@pytest.mark.skip(reason="fails in GH runner, passes on localhost") def test_parse_config2(tmp_path, create_configs): cfg = Configuration(tmp_path) ff = cfg.parse_config(['config.file0', 'config.file1'])