Repository navigation
flow: flow.sh runs the stage through RUN_CMD, like the rest of the flow #4555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
maliberty
merged 3 commits into
The-OpenROAD-Project:master
from
oharboe:flow-sh-honor-run-cmd
Sep 26, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
5ed1bc4
util: genElapsedTime parses the timing line wherever it sits on the line
oharboe 341991d
flow: flow.sh runs the stage through RUN_CMD, like the rest of the flow
oharboe c5d25be
Merge remote-tracking branch 'origin/master' into flow-sh-honor-run-cmd
oharboe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| #!/usr/bin/env python3 | ||
| """flow.sh runs every stage, and runs it through RUN_CMD like the rest of | ||
| the flow. With RUN_CMD unset, a stage runs exactly as before; with it set, | ||
| the stage goes through it and the per-stage summary still comes out. | ||
|
|
||
| The tools are stubbed: OPENROAD_EXE is `true` and OPENROAD_CMD is `echo`, | ||
| so the stage is quick and needs nothing installed. | ||
| """ | ||
|
|
||
| import os | ||
| import subprocess | ||
| import sys | ||
| import tempfile | ||
| import textwrap | ||
| import unittest | ||
|
|
||
| FLOW_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..") | ||
| SCRIPTS_DIR = os.path.join(FLOW_DIR, "scripts") | ||
| UTILS_DIR = os.path.join(FLOW_DIR, "util") | ||
|
|
||
|
|
||
| class TestFlowSh(unittest.TestCase): | ||
| def setUp(self): | ||
| self.tmp_dir = tempfile.TemporaryDirectory() | ||
| tmp = self.tmp_dir.name | ||
| self.log_dir = os.path.join(tmp, "logs") | ||
| self.env = dict( | ||
| os.environ, | ||
| RESULTS_DIR=os.path.join(tmp, "results"), | ||
| LOG_DIR=self.log_dir, | ||
| REPORTS_DIR=os.path.join(tmp, "reports"), | ||
| OBJECTS_DIR=os.path.join(tmp, "objects"), | ||
| SCRIPTS_DIR=SCRIPTS_DIR, | ||
| UTILS_DIR=UTILS_DIR, | ||
| PYTHON_EXE=sys.executable, | ||
| OPENROAD_EXE="true", | ||
| OPENROAD_ARGS="", | ||
| OPENROAD_CMD="echo", | ||
| ) | ||
| self.env.pop("RUN_CMD", None) | ||
|
|
||
| def tearDown(self): | ||
| self.tmp_dir.cleanup() | ||
|
|
||
| def run_stage(self): | ||
| result = subprocess.run( | ||
| [ | ||
| "bash", | ||
| os.path.join(SCRIPTS_DIR, "flow.sh"), | ||
| "2_1_floorplan", | ||
| "floorplan", | ||
| ], | ||
| env=self.env, | ||
| capture_output=True, | ||
| text=True, | ||
| ) | ||
| self.assertEqual(result.returncode, 0, result.stdout + result.stderr) | ||
| with open(os.path.join(self.log_dir, "2_1_floorplan.log")) as f: | ||
| return f.read() | ||
|
|
||
| def assert_summary(self, log): | ||
| # genElapsedTime.py's row for the stage: name, elapsed, peak memory. | ||
| rows = [line for line in log.splitlines() if line.startswith("2_1_floorplan")] | ||
| self.assertEqual(len(rows), 1, log) | ||
| self.assertGreaterEqual(len(rows[0].split()), 3, rows[0]) | ||
|
|
||
| def test_run_cmd_unset_runs_the_stage_as_before(self): | ||
| log = self.run_stage() | ||
| self.assertIn("Elapsed time:", log) | ||
| self.assert_summary(log) | ||
|
|
||
| def test_run_cmd_runs_the_stage(self): | ||
| # A RUN_CMD that records that it ran, then runs run_command.py. | ||
| marker = os.path.join(self.tmp_dir.name, "run_cmd_ran") | ||
| wrapper = os.path.join(self.tmp_dir.name, "run_cmd.py") | ||
| with open(wrapper, "w") as f: | ||
| f.write(textwrap.dedent(f"""\ | ||
| import os, sys | ||
| with open({marker!r}, "a") as m: | ||
| m.write(" ".join(sys.argv[1:]) + "\\n") | ||
| run_command = os.path.join({SCRIPTS_DIR!r}, "run_command.py") | ||
| os.execv(sys.executable, [sys.executable, run_command] + sys.argv[1:]) | ||
| """)) | ||
| self.env["RUN_CMD"] = f"{sys.executable} {wrapper}" | ||
|
|
||
| log = self.run_stage() | ||
|
|
||
| self.assertTrue(os.path.exists(marker), "RUN_CMD did not run the stage") | ||
| with open(marker) as f: | ||
| self.assertIn("floorplan.tcl", f.read()) | ||
| self.assertIn("Elapsed time:", log) | ||
| self.assert_summary(log) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.