Skip to content

refactor: use resolve_results_dir instead of hardcoded /tmp/results - #791

Closed
eltorrero wants to merge 1 commit into
projectbluefin:mainfrom
eltorrero:fix/results-dir-hardcoded
Closed

eltorrero wants to merge 1 commit into
projectbluefin:mainfrom
eltorrero:fix/results-dir-hardcoded

Conversation

@eltorrero

Copy link
Copy Markdown

Replace hardcoded /tmp/results paths with the resolve_results_dir helper in tests/shared/gnome_shell_steps.py and tests/smoke/features/environment.py (and its duplicate in tests/vanilla-gnome/features/environment.py).

This completes Step 2 of the recommendation in issue #779.

— hive: backend=goose

Signed-off-by: arch <arch@archlinux.local>

@kubestellar-hive kubestellar-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by @castrojo for Hive auto-merge on green CI.

@hanthor hanthor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import os was deleted but never replaced — this fails the Lint gate

In tests/vanilla-gnome/features/environment.py the diff removes the function-local import:

     try:
-        import os
-        if os.path.exists("/tmp/results/atspi_tree.txt"):
+        results_dir = resolve_results_dir(context)
+        if os.path.exists(os.path.join(results_dir, "atspi_tree.txt")):

but no module-level import os is added. The only thing that could bind os in that module is from qecore.common_steps import *.

Merging this branch onto main and running the exact command from pr-validate.yml:

$ ruff check tests/ scripts/ --select E,F,W --ignore E501
F405 `os` may be undefined, or defined from star imports
   --> tests/vanilla-gnome/features/environment.py:195:12
F405 ... :195:27
F405 ... :203:9
F405 ... :204:14
Found 4 errors.

On main the same command reports All checks passed!, so these four are introduced by this PR and Lint & syntax will fail.

At runtime it is worse than a lint nit: if qecore.common_steps does not re-export os, after_all raises NameError, and the surrounding except Exception: pass swallows it — atspi_tree.txt would silently stop being written with no failure anywhere.

Fix: add import os to the module-level imports of tests/vanilla-gnome/features/environment.py.

Minor

The new import is inserted between import sys and import traceback:

import sys
from tests.shared.results_dir import resolve_results_dir
import traceback

That puts a first-party import inside the stdlib block. It belongs with the other from tests.shared... imports below.

Note on CI status

This PR currently shows no check runs at all (total_count: 0) — the fork's workflows appear never to have been approved, so nothing has actually validated it. The three other files in the diff look correct to me; it is only tests/vanilla-gnome that is broken.


Generated by Claude Code

@castrojo

Copy link
Copy Markdown
Collaborator

Closing as a duplicate of #825, which implements the same change without a regression.

#791, #823 and #825 all route the AT-SPI tree dump through resolve_results_dir at the same three call sites; your tests/shared/gnome_shell_steps.py post-image is in fact byte-identical to #825's. None of the three is superseded by main.

The blocker here is the one @hanthor already identified, and it still stands: tests/vanilla-gnome/features/environment.py drops the function-local import os from after_all and adds no module-level replacement. That module's header is import sys / import traceback — there is no import os. The four os. uses then resolve only through from qecore.common_steps import *, which is F405 under the required ruff check tests/ scripts/ --select E,F,W gate, and at runtime a NameError swallowed by the surrounding except Exception: passatspi_tree.txt would silently stop being written with nothing failing.

Secondary: the new unit test patches tests.shared.gnome_shell_steps.resolve_results_dir to return "/tmp/results", which mocks out the precedence chain it is meant to cover.

#825 carries the same production change with both imports intact, plus tests that exercise the real resolver. Track it there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants