aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUsta (Tsering) Shrestha <usta@google.com>2023-04-18 02:24:10 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-04-18 02:24:10 +0000
commita056dea23f12fe32bcfbbc36cf16f8b85e4b983d (patch)
tree14a544b119891edd607c751f422905df93496ebe
parent7a3b3aed252452850287d5d039a7743c22cfd797 (diff)
parent949180ea4b00f405ae49d97043d363cbafe91fa1 (diff)
downloadbazel-a056dea23f12fe32bcfbbc36cf16f8b85e4b983d.tar.gz
Merge changes I6773b80c,I9b81bbf7 am: 50f7e3212f am: 6847d6043b am: 6be668fce6 am: 949180ea4b
Original change: https://android-review.googlesource.com/c/platform/build/bazel/+/2541670 Change-Id: I6bab6f71ae7d2a839982ae010cc8109531f3ee54 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--scripts/incremental_build/cuj_catalog.py19
-rw-r--r--scripts/incremental_build/perf_metrics.py11
-rw-r--r--scripts/incremental_build/perf_metrics_test.py5
-rw-r--r--scripts/incremental_build/util_test.py4
4 files changed, 22 insertions, 17 deletions
diff --git a/scripts/incremental_build/cuj_catalog.py b/scripts/incremental_build/cuj_catalog.py
index 6db3c8d8..7d2de238 100644
--- a/scripts/incremental_build/cuj_catalog.py
+++ b/scripts/incremental_build/cuj_catalog.py
@@ -64,20 +64,15 @@ def verify_symlink_forest_has_only_symlink_leaves():
files except for merged BUILD.bazel files"""
top_in_ws = InWorkspace.ws_counterpart(util.get_top_dir())
- def helper(d: Path):
- for child in os.scandir(d):
- child_path: Path = Path(child.path)
- if child_path.name == 'symlink_forest_version' and d == top_in_ws:
- continue
- if child_path.is_symlink():
+
+ for root, dirs, files in os.walk(top_in_ws, topdown=True, followlinks=False):
+ for file in files:
+ if file == 'symlink_forest_version' and top_in_ws.samefile(root):
continue
- if child_path.is_file() and child.name != 'BUILD.bazel':
- # only "merged" BUILD.bazel files expected
- raise AssertionError(f'{child_path} is an unexpected file')
- if child_path.is_dir():
- helper(child_path)
+ f = Path(root).joinpath(file)
+ if file != 'BUILD.bazel' and not f.is_symlink():
+ raise AssertionError(f'{f} unexpected')
- helper(top_in_ws)
logging.info('VERIFIED Symlink Forest has no real files except BUILD.bazel')
diff --git a/scripts/incremental_build/perf_metrics.py b/scripts/incremental_build/perf_metrics.py
index 3d074566..64512e73 100644
--- a/scripts/incremental_build/perf_metrics.py
+++ b/scripts/incremental_build/perf_metrics.py
@@ -181,10 +181,12 @@ def _get_column_headers(rows: list[Row], allow_cycles: bool) -> list[str]:
prev_col = all_cols[col]
acc = []
- while len(all_cols) > 0:
- entries = [c for c in all_cols.values()]
- entries.sort(key=lambda c: f'{c.indegree:03d}{c.header}')
- entry = entries[0]
+ entries = [c for c in all_cols.values()]
+ while len(entries) > 0:
+ # sorting alphabetically to break ties for concurrent events
+ entries.sort(key=lambda c: c.header, reverse=True)
+ entries.sort(key=lambda c: c.indegree, reverse=True)
+ entry = entries.pop()
# take only one to maintain alphabetical sort
if entry.indegree != 0:
cycle = '->'.join(entry.dfs(entry.header))
@@ -200,7 +202,6 @@ def _get_column_headers(rows: list[Row], allow_cycles: bool) -> list[str]:
else:
if not allow_cycles:
raise ValueError(f'unexpected error for: {n}')
- all_cols.pop(entry.header)
return acc
diff --git a/scripts/incremental_build/perf_metrics_test.py b/scripts/incremental_build/perf_metrics_test.py
index a25c4405..119bdc10 100644
--- a/scripts/incremental_build/perf_metrics_test.py
+++ b/scripts/incremental_build/perf_metrics_test.py
@@ -40,6 +40,7 @@ class PerfMetricsTest(unittest.TestCase):
Example(['ac', 'bd'], 'abcd'),
Example(['abe', 'cde'], 'abcde'),
Example(['ab', 'ba'], 'ab'),
+ Example(['abcde', 'edcba'], 'abcde'),
Example(['ac', 'abc'], 'abc')
]
for e in examples:
@@ -60,3 +61,7 @@ class PerfMetricsTest(unittest.TestCase):
with self.assertRaisesRegex(ValueError,
f'event ordering has a cycle {cycle}'):
_get_column_headers(rows, allow_cycles=False)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/scripts/incremental_build/util_test.py b/scripts/incremental_build/util_test.py
index 01b5f9c2..b117bd74 100644
--- a/scripts/incremental_build/util_test.py
+++ b/scripts/incremental_build/util_test.py
@@ -101,3 +101,7 @@ class UtilTest(unittest.TestCase):
for (ts, expected) in examples:
self.subTest(ts=ts, expected=expected)
self.assertEqual(period_to_seconds(ts), expected)
+
+
+if __name__ == '__main__':
+ unittest.main()