|
14 | 14 |
|
15 | 15 | import os |
16 | 16 | import subprocess |
| 17 | +import sys |
17 | 18 | import tempfile |
18 | | -import textwrap |
19 | 19 | import unittest |
20 | 20 |
|
21 | 21 | FLOW_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..") |
@@ -150,6 +150,46 @@ def test_generated_rules_run_the_command(self): |
150 | 150 | self.assertIn(flag, call.split()) |
151 | 151 | self.assertTrue(call.endswith("open.tcl"), call) |
152 | 152 |
|
| 153 | + def test_synth_sh_keeps_a_quoted_wrapper_argument_whole(self): |
| 154 | + # YOSYS_EXE="wrapper -ex 'two words' yosys": synth.sh hands the |
| 155 | + # wrapper the quoted argument as one argument, both times it runs it. |
| 156 | + tmp = self.tmp_dir.name |
| 157 | + wrapper = self.script( |
| 158 | + "argv", 'printf "%s|" "$@" >> "$ARGV_LOG"\necho >> "$ARGV_LOG"\n' |
| 159 | + ) |
| 160 | + scripts = os.path.join(FLOW_DIR, "scripts") |
| 161 | + env = dict( |
| 162 | + self.env, |
| 163 | + RESULTS_DIR=os.path.join(tmp, "results"), |
| 164 | + LOG_DIR=os.path.join(tmp, "logs"), |
| 165 | + REPORTS_DIR=os.path.join(tmp, "reports"), |
| 166 | + OBJECTS_DIR=os.path.join(tmp, "objects"), |
| 167 | + SCRIPTS_DIR=scripts, |
| 168 | + UTILS_DIR=os.path.join(FLOW_DIR, "util"), |
| 169 | + PYTHON_EXE=sys.executable, |
| 170 | + YOSYS_EXE=f"{wrapper} -ex 'two words' yosys", |
| 171 | + YOSYS_FLAGS="-v 3", |
| 172 | + ) |
| 173 | + result = subprocess.run( |
| 174 | + [ |
| 175 | + "bash", |
| 176 | + os.path.join(scripts, "synth.sh"), |
| 177 | + "synth.tcl", |
| 178 | + os.path.join(tmp, "logs", "1_2_yosys.log"), |
| 179 | + ], |
| 180 | + cwd=tmp, |
| 181 | + env=env, |
| 182 | + capture_output=True, |
| 183 | + text=True, |
| 184 | + ) |
| 185 | + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) |
| 186 | + with open(self.log) as f: |
| 187 | + calls = f.read().splitlines() |
| 188 | + self.assertEqual( |
| 189 | + calls, |
| 190 | + ["-ex|two words|yosys|-V|", "-ex|two words|yosys|-v|3|-c|synth.tcl|"], |
| 191 | + ) |
| 192 | + |
153 | 193 | def test_gdb_and_valgrind_are_not_switches(self): |
154 | 194 | # a debugger or valgrind goes in OPENROAD_EXE; GDB and VALGRIND |
155 | 195 | # set to anything leave the command as it is |
|
0 commit comments