Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3006.x][Batch 13] Increase code coverage on state module saltmod #65372

Merged
merged 12 commits into from
Oct 16, 2023
Merged
1 change: 1 addition & 0 deletions changelog/65372.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test mode for state function `saltmod.wheel` no longer set's `result` to `(None,)`
66 changes: 43 additions & 23 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1246,32 +1246,52 @@ def decompress_dependencies(session):
else:
scan_path = REPO_ROOT.joinpath(".nox", dirname, "Scripts")
script_paths = {str(p): p for p in os.scandir(scan_path)}
fixed_shebang = f"#!{scan_path / 'python'}"
for key in sorted(script_paths):
path = script_paths[key]
if not path.is_symlink():
if path.is_symlink():
s0undt3ch marked this conversation as resolved.
Show resolved Hide resolved
broken_link = pathlib.Path(path)
resolved_link = os.readlink(path)
if not os.path.isabs(resolved_link):
# Relative symlinks, resolve them
resolved_link = os.path.join(scan_path, resolved_link)
if not os.path.exists(resolved_link):
session.log("The symlink %r looks to be broken", resolved_link)
# This is a broken link, fix it
resolved_link_suffix = resolved_link.split(
f"artifacts{os.sep}salt{os.sep}"
)[-1]
fixed_link = REPO_ROOT.joinpath(
"artifacts", "salt", resolved_link_suffix
)
session.log(
"Fixing broken symlink in nox virtualenv %r, from %r to %r",
dirname.name,
resolved_link,
str(fixed_link.relative_to(REPO_ROOT)),
)
broken_link.unlink()
broken_link.symlink_to(fixed_link)
continue
if not path.is_file():
continue
broken_link = pathlib.Path(path)
resolved_link = os.readlink(path)
if not os.path.isabs(resolved_link):
# Relative symlinks, resolve them
resolved_link = os.path.join(scan_path, resolved_link)
if not os.path.exists(resolved_link):
session.log("The symlink %r looks to be broken", resolved_link)
# This is a broken link, fix it
resolved_link_suffix = resolved_link.split(
f"artifacts{os.sep}salt{os.sep}"
)[-1]
fixed_link = REPO_ROOT.joinpath(
"artifacts", "salt", resolved_link_suffix
)
session.log(
"Fixing broken symlink in nox virtualenv %r, from %r to %r",
dirname.name,
resolved_link,
str(fixed_link.relative_to(REPO_ROOT)),
)
broken_link.unlink()
broken_link.symlink_to(fixed_link)
if "windows" not in distro_slug:
# Let's try to fix shebang's
try:
fpath = pathlib.Path(path)
contents = fpath.read_text().splitlines()
if (
contents[0].startswith("#!")
and contents[0].endswith("python")
and contents[0] != fixed_shebang
):
session.log(
"Fixing broken shebang in %r",
str(fpath.relative_to(REPO_ROOT)),
)
fpath.write_text("\n".join([fixed_shebang] + contents[1:]))
except UnicodeDecodeError:
pass


@nox.session(python=False, name="compress-dependencies")
Expand Down
2 changes: 1 addition & 1 deletion salt/states/saltmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ def wheel(name, **kwargs):
jid = None

if __opts__.get("test", False):
ret["result"] = (None,)
ret["result"] = None
ret["changes"] = {}
ret["comment"] = "Wheel function '{}' would be executed.".format(name)
return ret
Expand Down
Empty file.
Loading