Skip to content

Commit f5f5884

Browse files
test: run the printed override line without inherited variables
test_override_command_carries_prefix_ref_and_base_url ran the printed --force line with the fixture env, which already exports PYMOLSCRIPTS_REF and PYMOLSCRIPTS_BASE_URL, so a line that set neither for the installer still passed: moving the assignments onto curl's side of the pipe (install.sh) or commenting out the $env: assignments (install.ps1) left all tests green. The line now runs with both variables pointing where the local server publishes nothing, so it succeeds only when it sets them itself; both mutations fail with a local 404. Unsetting them instead would let a broken line fall back to the real base URL.
1 parent 791039e commit f5f5884

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎tests/test_local_edits.py‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ def override_line(self, result):
6666
self.assertTrue(lines, self.describe(result))
6767
return lines[-1].strip()
6868

69+
def override_env(self):
70+
"""self.env with PYMOLSCRIPTS_REF and PYMOLSCRIPTS_BASE_URL pointing
71+
where the local server publishes nothing, so that a printed override
72+
line works only when it sets both itself. Unsetting them instead
73+
would let a broken line fall back to the real base URL."""
74+
return dict(
75+
self.env,
76+
PYMOLSCRIPTS_REF="wrongref",
77+
PYMOLSCRIPTS_BASE_URL=f"{self.server.base_url}/wrong",
78+
)
79+
6980
# --- recording ----------------------------------------------------------
7081

7182
def test_install_records_what_it_wrote(self):
@@ -375,7 +386,7 @@ def run_override(self, line):
375386
self.skipTest("curl not found")
376387
self.server.publish_script("testref", self.script_name)
377388
result = subprocess.run(
378-
["/bin/sh", "-c", line], env=self.env, stdin=subprocess.DEVNULL,
389+
["/bin/sh", "-c", line], env=self.override_env(), stdin=subprocess.DEVNULL,
379390
capture_output=True, timeout=180,
380391
)
381392
self.assertEqual(result.returncode, 0, self.describe(result))
@@ -437,7 +448,7 @@ def run_override(self, line):
437448
self.server.publish_script("testref", self.script_name)
438449
result = subprocess.run(
439450
[self.exe, "-NoLogo", "-NoProfile", "-NonInteractive", "-Command", line],
440-
env=self.env, stdin=subprocess.DEVNULL, capture_output=True, timeout=180,
451+
env=self.override_env(), stdin=subprocess.DEVNULL, capture_output=True, timeout=180,
441452
)
442453
self.assertEqual(result.returncode, 0, self.describe(result))
443454

0 commit comments

Comments
 (0)