Skip to content

Commit

Permalink
Final fix for test_script failures
Browse files Browse the repository at this point in the history
  • Loading branch information
twangboy committed Jan 27, 2025
1 parent ec04e88 commit 701e782
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 35 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,7 @@ jobs:
RAISE_DEPRECATIONS_RUNTIME_ERRORS: "1"
SALT_TRANSPORT: ${{ matrix.transport }}
TMPDIR: ${{ runner.temp }}
shell: powershell
run: >
nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} --
-k "win" --suppress-no-test-exit-code
Expand All @@ -1145,6 +1146,7 @@ jobs:
RAISE_DEPRECATIONS_RUNTIME_ERRORS: "1"
SALT_TRANSPORT: ${{ matrix.transport }}
TMPDIR: ${{ runner.temp }}
shell: powershell
run: >
nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} --
-k "win" --suppress-no-test-exit-code --no-fast-tests --slow-tests
Expand All @@ -1171,6 +1173,7 @@ jobs:
RAISE_DEPRECATIONS_RUNTIME_ERRORS: "1"
SALT_TRANSPORT: ${{ matrix.transport }}
TMPDIR: ${{ runner.temp }}
shell: powershell
run: >
nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} --
-k "win" --suppress-no-test-exit-code --no-fast-tests --core-tests
Expand All @@ -1197,6 +1200,7 @@ jobs:
RAISE_DEPRECATIONS_RUNTIME_ERRORS: "1"
SALT_TRANSPORT: ${{ matrix.transport }}
TMPDIR: ${{ runner.temp }}
shell: powershell
run: >
nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} --
-k "win" --suppress-no-test-exit-code --no-fast-tests --flaky-jail
Expand All @@ -1223,6 +1227,7 @@ jobs:
RAISE_DEPRECATIONS_RUNTIME_ERRORS: "1"
SALT_TRANSPORT: ${{ matrix.transport }}
TMPDIR: ${{ runner.temp }}
shell: powershell
run: >
nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} --
--slow-tests --core-tests -k "win" --test-group-count=${{ matrix.test-group-count || 1 }} --test-group=${{ matrix.test-group || 1 }}
Expand Down
29 changes: 0 additions & 29 deletions salt/modules/cmdmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2942,35 +2942,6 @@ def _cleanup_tempfile(path):
cmd_path = _cmd_quote(path, escape=False)
else:
cmd_path = path
# import pathlib
# 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": ""})
else:
cmd_path = _cmd_quote(path)

Expand Down
7 changes: 1 addition & 6 deletions tests/pytests/functional/modules/cmd/test_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,7 @@ def test_windows_script_args_powershell(cmd, shell, issue_56195):
)
script = "salt://issue-56195/test.ps1"

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)
ps_module_path = cmd.run("$env:PSModulePath", shell=shell)
ret = cmd.script(source=script, args=args, shell=shell, saltenv="base")

assert ret["stdout"] == password

Expand Down

0 comments on commit 701e782

Please sign in to comment.