Skip to content

Commit fdca039

Browse files
oharboeclaude
andcommitted
generate_vars: the vars files are written afresh
`make vars` wrote the .sh and .tcl files afresh and appended to the .gdb file, so after a few runs it held every earlier run's variables too and gdb set each one again, from the oldest value to the newest. All three are written afresh now; makeIssue.py no longer removes them first. TestWrittenAfresh writes the files twice and finds only the second value; the .gdb file held both before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 1b60b2b commit fdca039

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

‎flow/test/test_generate_vars.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,26 @@ def test_scripts_dir_next_to_the_vars(self):
196196
self.assertIn('set env(SCRIPTS_DIR) "./scripts"', lines["tcl"])
197197

198198

199+
class TestWrittenAfresh(VarsTestCase):
200+
"""`make vars` run again writes the files afresh: the .gdb file held
201+
every earlier run's variables too, and gdb set each one again from
202+
the oldest value to the newest."""
203+
204+
def test_written_afresh(self):
205+
self.generate("A=old\n")
206+
lines = self.generate("A=new\n")
207+
for ext, line in [
208+
("sh", 'export A="new"'),
209+
("tcl", 'set env(A) "new"'),
210+
("gdb", "set env A new"),
211+
]:
212+
self.assertEqual(
213+
[l for l in lines[ext] if "A" in l and "PYTHON" not in l],
214+
[line],
215+
ext,
216+
)
217+
218+
199219
class TestCommandLine(VarsTestCase):
200220
"""The flow's Makefile runs it as `generate_vars.py <basename>` with
201221
the variables in its environment."""

‎flow/util/generate_vars.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ def relative_value(name, value, env, flow_root, orfs_root, work_root):
115115

116116

117117
def write_vars(basename, env):
118-
"""Writes <basename>.sh and <basename>.tcl, and appends to
119-
<basename>.gdb, from env's ISSUE_VARIABLES."""
118+
"""Writes <basename>.sh, .tcl and .gdb from env's ISSUE_VARIABLES."""
120119
flow_root = os.path.realpath(env["FLOW_HOME"])
121120
orfs_root = os.path.realpath(env["FLOW_HOME"] + "/../")
122121
work_root = os.path.realpath(env.get("WORK_HOME") or ".")
@@ -136,8 +135,8 @@ def write_vars(basename, env):
136135
tcl.append(f'set env({name}) "{value}"\n')
137136
gdb.append(f"set env {name} {value}\n")
138137

139-
for ext, lines, mode in [("sh", sh, "w"), ("tcl", tcl, "w"), ("gdb", gdb, "a")]:
140-
with open(f"{basename}.{ext}", mode) as f:
138+
for ext, lines in [("sh", sh), ("tcl", tcl), ("gdb", gdb)]:
139+
with open(f"{basename}.{ext}", "w") as f:
141140
f.write("".join(lines))
142141

143142

‎flow/util/makeIssue.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,6 @@ def make_issue(target, env):
223223
run_me_script, run_me_text(env, issue_target, vars_basename, yosys)
224224
)
225225

226-
for ext in ["sh", "tcl", "gdb"]:
227-
if os.path.exists(f"{vars_basename}.{ext}"):
228-
os.remove(f"{vars_basename}.{ext}")
229226
generate_vars.write_vars(vars_basename, env)
230227

231228
issue_name = f"{issue_target}_{issue_tag}"

0 commit comments

Comments
 (0)