mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Clear the environment in the test
This commit is contained in:
parent
48647c2080
commit
3f686c2e89
2 changed files with 29 additions and 32 deletions
|
@ -2943,38 +2943,34 @@ def script(
|
|||
cmd_path = _cmd_quote(path, escape=False)
|
||||
else:
|
||||
cmd_path = path
|
||||
if not env:
|
||||
env = {}
|
||||
if shell.lower() == "powershell":
|
||||
mod_paths = [
|
||||
pathlib.Path(
|
||||
rf'{os.getenv("SystemRoot")}\System32\WindowsPowerShell\v1.0\Modules'
|
||||
),
|
||||
pathlib.Path(
|
||||
rf'{os.getenv("ProgramFiles")}\WindowsPowerShell\Modules'
|
||||
),
|
||||
]
|
||||
else:
|
||||
mod_paths = [
|
||||
pathlib.Path(rf'{os.getenv("ProgramFiles")}\PowerShell\Modules'),
|
||||
pathlib.Path(
|
||||
rf'{os.getenv("ProgramFiles")}\PowerShell\6.0.0\Modules'
|
||||
),
|
||||
pathlib.Path(rf'{os.getenv("ProgramFiles")}\PowerShell\7\Modules'),
|
||||
]
|
||||
ps_module_path = [
|
||||
pathlib.Path(x) for x in os.getenv("PSModulePath", "").split(";")
|
||||
]
|
||||
for mod_path in mod_paths:
|
||||
if mod_path.exists():
|
||||
if mod_path not in ps_module_path:
|
||||
ps_module_path.append(mod_path)
|
||||
mod_paths = ""
|
||||
for mod_path in ps_module_path:
|
||||
if mod_path:
|
||||
mod_paths += f"{str(path)};"
|
||||
# if not env:
|
||||
# env = {}
|
||||
# if shell.lower() == "powershell":
|
||||
# mod_paths = [
|
||||
# pathlib.Path(
|
||||
# rf'{os.getenv("SystemRoot")}\System32\WindowsPowerShell\v1.0\Modules'
|
||||
# ),
|
||||
# pathlib.Path(rf'{os.getenv("ProgramFiles")}\WindowsPowerShell\Modules'),
|
||||
# ]
|
||||
# else:
|
||||
# mod_paths = [
|
||||
# pathlib.Path(rf'{os.getenv("ProgramFiles")}\PowerShell\Modules'),
|
||||
# pathlib.Path(rf'{os.getenv("ProgramFiles")}\PowerShell\6.0.0\Modules'),
|
||||
# pathlib.Path(rf'{os.getenv("ProgramFiles")}\PowerShell\7\Modules'),
|
||||
# ]
|
||||
# ps_module_path = [
|
||||
# pathlib.Path(x) for x in os.getenv("PSModulePath", "").split(";")
|
||||
# ]
|
||||
# for mod_path in mod_paths:
|
||||
# if mod_path.exists():
|
||||
# if mod_path not in ps_module_path:
|
||||
# ps_module_path.append(mod_path)
|
||||
# mod_paths = ""
|
||||
# for mod_path in ps_module_path:
|
||||
# if mod_path:
|
||||
# mod_paths += f"{str(path)};"
|
||||
# env.update({"PSModulePath": mod_paths})
|
||||
env.update({"PSModulePath": ""})
|
||||
# env.update({"PSModulePath": ""})
|
||||
else:
|
||||
cmd_path = _cmd_quote(path)
|
||||
|
||||
|
|
|
@ -57,7 +57,8 @@ def test_windows_script_args_powershell(cmd, shell, issue_56195):
|
|||
)
|
||||
script = "salt://issue-56195/test.ps1"
|
||||
|
||||
ret = cmd.script(source=script, args=args, shell=shell, saltenv="base")
|
||||
ps_path = {"PSModulePath": ""}
|
||||
ret = cmd.script(source=script, args=args, shell=shell, saltenv="base", env=ps_path)
|
||||
|
||||
import_result = cmd.run("Import-Module Microsoft.PowerShell.Security", shell=shell)
|
||||
powershell_version = cmd.run("$PSVersionTable", shell=shell)
|
||||
|
|
Loading…
Add table
Reference in a new issue