Skip to content

Commit d25c3c5

Browse files
oharboeclaude
andcommitted
test: the vars hold the flow's variables, not make's or the machine's
The vars files have been taught, one fix at a time, which variables mean nothing on another machine: make's step and copy macros (#1240, #1231) and its other internals, commands, executables, the shell and search paths, and names that are not shell names (#1303, #1331), FLOW_HOME, which the shell file sets once from where it is sourced (#1380), make's newline macro (#1386), and CURDIR and the GUI switches (#1410). A variable named *_DIR stays (#1331). TestLeftOut checks each of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 1fd41f1 commit d25c3c5

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

‎flow/test/test_generate_vars.py‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,58 @@ def test_work_home_resolved_from_the_working_directory(self):
8484
self.assertIn(mock.call(self.flow), realpath.call_args_list)
8585

8686

87+
class TestLeftOut(VarsTestCase):
88+
"""The vars hold the flow's and the design's variables, not make's own
89+
or the machine's, which mean nothing elsewhere: make's step and copy
90+
macros (#1240, #1231) and its other internals, commands, executables,
91+
the shell and search paths (#1303), names that are not shell names
92+
(#1303, #1331), FLOW_HOME, which the shell file sets once from where
93+
it is sourced (#1380), the newline macro (#1386), and CURDIR and the
94+
GUI switches (#1410). Variables named *_DIR stay (#1331)."""
95+
96+
LEFT_OUT = [
97+
"do-step",
98+
"do-copy",
99+
"get_variables",
100+
"UNSET_VARIABLES_NAMES",
101+
"MAKE",
102+
"MAKEFLAGS",
103+
"MAKEFILE_LIST",
104+
"OPENROAD_EXE",
105+
"YOSYS_EXE",
106+
"OPENROAD_CMD",
107+
"TIME_CMD",
108+
"SHELL",
109+
"HOME",
110+
"PWD",
111+
"LD_LIBRARY_PATH",
112+
"PATH",
113+
"NPROC",
114+
"NUM_CORES",
115+
"FLOW_HOME",
116+
"\\n",
117+
"CURDIR",
118+
"OPEN_GUI",
119+
"OPEN_GUI_SHORTCUT",
120+
"COMMAND_LINE_ARGS",
121+
"a.b",
122+
"1ST",
123+
]
124+
125+
def test_left_out(self):
126+
lines = self.generate("".join(f"{name}=x\n" for name in self.LEFT_OUT))
127+
for ext, header in [("sh", 2), ("tcl", 1), ("gdb", 0)]:
128+
self.assertEqual(lines[ext][header:], [], ext)
129+
130+
def test_dir_variables_stay(self):
131+
lines = self.generate("RESULTS_DIR=results\n")
132+
self.assertIn('export RESULTS_DIR="results"', lines["sh"])
133+
134+
def test_flow_home_set_once(self):
135+
sh = self.generate(f"FLOW_HOME={self.flow}\n")["sh"]
136+
self.assertEqual([l for l in sh if "FLOW_HOME=" in l], [sh[0]])
137+
138+
87139
class TestCommandLine(VarsTestCase):
88140
"""The flow's Makefile runs it as `generate_vars.py <basename>` with
89141
the variables in its environment."""

0 commit comments

Comments
 (0)