File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ bazel run //scripts/tooling -- misc --help
1313## Creating HTML report
1414
1515``` bash
16- bazel run //scripts/tooling -- misc html_report --output /home/pawel/score/repos/reference_integration/report.html
16+ bazel run //scripts/tooling -- misc html_report
1717```
1818
1919## Running tests
Original file line number Diff line number Diff line change 11import argparse
2+ import os
23import sys
34from pathlib import Path
45
56
7+ def _resolve_path_from_bazel (path : Path ) -> Path :
8+ """Resolve path relative to user's working directory when running via bazel run.
9+
10+ Bazel sets BUILD_WORKING_DIRECTORY to the directory where bazel was invoked.
11+ """
12+ if not path .is_absolute ():
13+ # When running via 'bazel run', resolve relative paths against the user's cwd
14+ build_working_dir = os .environ .get ("BUILD_WORKING_DIRECTORY" )
15+ if build_working_dir :
16+ return (Path (build_working_dir ) / path ).resolve ()
17+ return path .resolve ()
18+
19+
620def _find_repo_root () -> Path :
721 """Walk up from this file to find the repo root (contains known_good.json)."""
822 candidate = Path (__file__ ).resolve ()
@@ -23,8 +37,7 @@ def _cmd_html_report(args: argparse.Namespace) -> int:
2337 print (f"error: { exc } " , file = sys .stderr )
2438 return 1
2539
26- output = Path (args .output ) if args .output else Path ("report.html" )
27- output = output .resolve ()
40+ output = _resolve_path_from_bazel (Path (args .output ))
2841 write_report (known_good , output )
2942 print (f"Report written to { output } " )
3043 return 0
You can’t perform that action at this time.
0 commit comments