Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Split the bump candidates into a short first table and a collapsed patched-files list (#464)

v0lumehie338a34513a4
diff --git a/patches/README.md b/patches/README.md
index d93fde4c..489fdd9e 100644
--- a/patches/README.md
+++ b/patches/README.md
@@ -62,10 +62,7 @@ python3 tools/engine.py relink # the links into seedds/nxnative in
```
`bump` needs the new upstream commit, which it fetches into `engine/` itself. Scratch worktrees go to `$PATCHES_TMP` (or `--tmp`), else
-the system's temporary folder. After a bump (also `--dry`) it prints a table of candidate commits between the old and the new pin: those that touch the shader
-chain, an env row, the NSP script, the launcher interface, a binary layout, or a file one of our patches changes (`tools/bump_candidates.py`, #464). It reads
-the commits' files with `gh api`, so it needs `gh`, and it never fails the bump. It is a list of candidates, not a verdict: whoever reviews the sync pull request
-reads those commits and fills the `Handled` column. The nightly job puts the table in the body of the `sync/upstream-<sha>` pull request. `dm/fork_patches.txt` is generated by `sync` inside `engine/` (one patch name per line). Do not edit it.
+the system's temporary folder. After a bump (also `--dry`) it prints two tables of the upstream commits between the old and the new pin (`tools/bump_candidates.py`, #464). The first, "Likely matters to the front ends", has the commits that touch the shader chain (consecutive chain moves are one row with the first and the last value), an env row that was removed or rewritten, the NSP script's interface or an error text a failure row matches, the launcher interface, or a binary layout. The second, collapsed, lists the commits whose only match is a file one of our patches changes: `bump` and `sync` already apply the patches and fail on a conflict, so read those only when a patch applied but its behavior might have shifted. It reads the commits' files with `gh api`, so it needs `gh`, and it never fails the bump. It is a list of candidates, not a verdict: whoever reviews the sync pull request reads the first table and fills its `Handled` column. The nightly job puts the first table in the body of the `sync/upstream-<sha>` pull request and the second in a `<details>` block. `dm/fork_patches.txt` is generated by `sync` inside `engine/` (one patch name per line). Do not edit it.
## Carrying a quick fix, and sending it upstream
diff --git a/tools/bump_candidates.py b/tools/bump_candidates.py
index 44b51b4a..edc1bbc9 100644
--- a/tools/bump_candidates.py
+++ b/tools/bump_candidates.py
@@ -6,6 +6,11 @@ shader chain, change a script message that a failure row matches, or rewrite a s
commits between two pins and prints the ones that touch something we depend on, as a Markdown table with an empty `Handled`
column. It is a list of candidates, not a verdict: a person reads those commits and writes "handled" or an issue number.
+The output is two tables. The first, "Likely matters to the front ends", has the commits that match any rule below except the last one,
+with consecutive commits that move the shader chain folded into one row (every sha, the chain value before and after, the other reasons).
+The second, a collapsed list, has the commits whose only match is a file that one of our patches changes: bump and sync already apply the
+patches and fail on a conflict. A commit of the first table is not repeated in the second.
+
A commit is a candidate when it
- has a `Breaking:` line or a "For front ends" section in its message (listed first),
- touches the shader chain (dmsh_chain.h, dmsh_chain.lock) or own_compilers.py (a chain move or a tool requirement),
@@ -189,7 +194,7 @@ def file_reasons(f, ctx):
name, patch = f['filename'], f.get('patch') or ''
base = name.rsplit('/', 1)[-1]
why = []
- if base in CHAIN: why.append('shader chain moves: every game built with the old chain is rebuilt (#449)')
+ if base in CHAIN: why.append(CHAIN_WHY)
if base == OWN_COMPILERS: why.append('tool requirement or chain input (own_compilers.py): a new minimum, or a rebuild')
if name == ENV_TSV:
if not patch: why.append('env_switches.tsv changed (no diff to read)')
@@ -216,48 +221,105 @@ def file_reasons(f, ctx):
return why
+CHAIN_WHY = 'shader chain moves: every game built with the old chain is rebuilt (#449)'
+
+
+def chain_values(files):
+ """(before, after) of DMSH_CHAIN from the diff of dmsh_chain.h in a commit's files, or None."""
+ for f in files:
+ if f['filename'].rsplit('/', 1)[-1] == 'dmsh_chain.h':
+ old = re.search(r'^-#define DMSH_CHAIN "([0-9a-f]+)"', f.get('patch') or '', re.M)
+ new = re.search(r'^\+#define DMSH_CHAIN "([0-9a-f]+)"', f.get('patch') or '', re.M)
+ if old and new: return old.group(1), new.group(1)
+ return None
+
+
def find_candidates(commits, ctx):
- """Rows {sha, title, files, why, breaking} for the commits that touch something we depend on. Breaking ones first, then in range order."""
+ """One row per commit that touches something we depend on, in range order, the ones with a Breaking: line first:
+ {sha, title, files, why, breaking, likely, patched, chain, chain_only (the chain moves)}. `likely` is false when the only match is a file one of our
+ patches changes (`patched`: [file (patch numbers)]), the second table. Grouping into table rows is group_rows."""
rows = []
for c in commits:
- files, whys = [], []
+ files, whys, patched = [], [], []
for f in c['files']:
w = file_reasons(f, ctx)
- if w:
+ hooks = [x[len(HOOK):] for x in w if x.startswith(HOOK)]
+ rest = [x for x in w if not x.startswith(HOOK)]
+ patched += hooks
+ if rest:
files.append(f['filename'])
- whys += [x for x in w if x not in whys]
- hooks = [w[len(HOOK):] for w in whys if w.startswith(HOOK)]
- whys = [w for w in whys if not w.startswith(HOOK)] + (['files our patches change: ' + ', '.join(hooks)] if hooks else [])
+ whys += [x for x in rest if x not in whys]
brk = breaking(c['message'])
if brk: whys.insert(0, 'the message says Breaking: or has a "For front ends" section')
- if files or brk:
- rows.append({'sha': c['sha'], 'title': c['message'].splitlines()[0] if c['message'] else '', 'files': files, 'why': whys, 'breaking': brk})
+ if files or brk or patched:
+ rows.append({'sha': c['sha'], 'title': c['message'].splitlines()[0] if c['message'] else '', 'files': files, 'why': whys, 'breaking': brk,
+ 'likely': bool(files or brk), 'patched': patched, 'chain': chain_values(c['files']),
+ 'chain_only': CHAIN_WHY in whys and not brk})
return sorted(rows, key=lambda r: not r['breaking']) # sorted is stable
+def group_rows(rows):
+ """Table 1: the likely rows, where consecutive commits that move the shader chain become one row with every sha, the chain value before the
+ first and after the last, the number of moves and the other reasons of the members."""
+ out = []
+ for r in (r for r in rows if r['likely']):
+ r = dict(r, shas=[r['sha']])
+ if r['chain_only'] and out and out[-1]['chain_only']:
+ g = out[-1]
+ g['shas'].append(r['sha'])
+ g['files'] = sorted(set(g['files']) | set(r['files']))
+ g['why'] += [w for w in r['why'] if w not in g['why']]
+ g['chain'] = (g['chain'][0], r['chain'][1]) if g['chain'] and r['chain'] else None
+ else:
+ out.append(r)
+ for g in out:
+ if g['chain_only']:
+ n = len(g['shas'])
+ if n > 1: g['title'] = f'Shader chain moves {n} times'
+ val = f' from `{g["chain"][0]}` to `{g["chain"][1]}`' if g['chain'] else ''
+ g['why'] = [f'DMSH_CHAIN{val}: every game built with the old chain is rebuilt (#449)'] + [w for w in g['why'] if w != CHAIN_WHY]
+ return out
+
+
# ---- the output ----
def _cell(s):
return s.replace('|', '\\|').replace('\n', ' ')
-def format_table(rows, old, new, total):
- out = [f'## Candidate commits ({len(rows)} of {total}), `{old[:12]}...{new[:12]}`',
+def format_tables(rows, old, new, total):
+ t1 = group_rows(rows)
+ t2 = [r for r in rows if not r['likely']]
+ n1 = sum(len(g['shas']) for g in t1)
+ out = [f'## Candidate commits, `{old[:12]}...{new[:12]}`',
'',
- f'This is a list of candidates, not a verdict. It lists the commits that touch something the front ends or the players depend on '
- f'(the shader chain, env rows, the NSP script, the launcher interface, binary layouts, files our patches change). '
- f'A commit that is not here can still matter: read the compare when in doubt. Write "handled" or an issue number in the last column.',
+ f'This is a list of candidates, not a verdict. {n1 + len(t2)} of the {total} commits touch something the front ends or the players depend on. '
+ f'A commit that is in neither table can still matter: read the compare when in doubt. Write "handled" or an issue number in the last column of the first table.',
'',
f'Upstream: https://github.com/{UPSTREAM}/compare/{old[:12]}...{new[:12]}',
+ '',
+ f'### Likely matters to the front ends ({len(t1)} rows, {n1} commits)',
'']
- if not rows:
- return '\n'.join(out + ['No commit of the range matches.', ''])
- out += ['| Commit | Title | Files | Why | Handled |', '|---|---|---|---|---|']
- for r in rows:
- files = r['files'][:4]
- more = f' (+{len(r["files"]) - 4} more)' if len(r['files']) > 4 else ''
- out.append(f'| `{r["sha"][:8]}` | {_cell(r["title"][:90])} | {_cell(", ".join("`" + f + "`" for f in files) + more)} | {_cell("; ".join(r["why"][:3]))} | |')
- return '\n'.join(out + [''])
+ if t1:
+ out += ['| Commit | Title | Files | Why | Handled |', '|---|---|---|---|---|']
+ for r in t1:
+ files = r['files'][:4]
+ more = f' (+{len(r["files"]) - 4} more)' if len(r['files']) > 4 else ''
+ shas = ', '.join(f'`{s[:8]}`' for s in r['shas'])
+ out.append(f'| {shas} | {_cell(r["title"][:90])} | {_cell(", ".join("`" + f + "`" for f in files) + more)} | {_cell("; ".join(r["why"][:4]))} | |')
+ else:
+ out.append('No commit of the range matches.')
+ out += ['', '<details>', f'<summary>Touches files our patches change ({len(t2)} commits)</summary>', '',
+ '`tools/engine.py bump` and `sync` already apply the patches and fail on a conflict, so these need no reading, unless a patch did not conflict '
+ 'but its behavior might have shifted.', '']
+ if t2:
+ out += ['| Commit | Title | Patched file (patches) |', '|---|---|---|']
+ for r in t2:
+ p = r['patched']
+ out.append(f'| `{r["sha"][:8]}` | {_cell(r["title"][:90])} | {_cell(", ".join(p[:3]) + (f" (+{len(p) - 3} more)" if len(p) > 3 else ""))} |')
+ else:
+ out.append('None.')
+ return '\n'.join(out + ['', '</details>', ''])
def report(root, old, new, eng=None, api=None):
@@ -268,7 +330,7 @@ def report(root, old, new, eng=None, api=None):
commits = fetch_commits(old, new, eng, api)
except Exception as e:
return f'## Candidate commits\n\nNot made: {e}\n\nRun `python3 tools/engine.py candidates --from {old[:12]} --to {new[:12]}` when `gh` can reach GitHub.\n'
- return format_table(find_candidates(commits, context(root)), old, new, len(commits))
+ return format_tables(find_candidates(commits, context(root)), old, new, len(commits))
def main(argv=None):
diff --git a/tools/tests/fixtures/bump_range_v1_0_1.json b/tools/tests/fixtures/bump_range_v1_0_1.json
index 224be3e9..9f78d7d7 100644
--- a/tools/tests/fixtures/bump_range_v1_0_1.json
+++ b/tools/tests/fixtures/bump_range_v1_0_1.json
@@ -317,7 +317,7 @@
},
{
"filename": "dm/gfx/nvn/dmsh_chain.h",
- "patch": "@@ lines that match nothing left out @@"
+ "patch": "-#define DMSH_CHAIN \"e65a4ebd3322\"\n+#define DMSH_CHAIN \"a7dbbce711c3\""
},
{
"filename": "dm/gfx/tools/dmsh_chain.lock",
@@ -419,7 +419,7 @@
},
{
"filename": "dm/games/01007EF00011E000/validated.tsv",
- "patch": "@@ lines that match nothing left out @@"
+ "patch": "+# mode <TAB> chain=<DMSH_CHAIN> commit=<short SHA>[+dirty] date=<UTC day> machine=<model> macos=<version>. No game data."
},
{
"filename": "dm/games/0100F2C0115B6000/README.md",
@@ -963,7 +963,7 @@
},
{
"filename": "dm/gfx/tests/t_pso_warm.m",
- "patch": "@@ lines that match nothing left out @@"
+ "patch": "+ NSDictionary *reflection = @{@\"chain\": @DMSH_CHAIN, @\"gs_slice\": @{@\"loc\": @0, @\"comp\": @\"x\"}};"
},
{
"filename": "docs/agents/symptoms.md",
@@ -1247,7 +1247,7 @@
},
{
"filename": "dm/gfx/nvn/dmsh_chain.h",
- "patch": "@@ lines that match nothing left out @@"
+ "patch": "-#define DMSH_CHAIN \"a7dbbce711c3\"\n+#define DMSH_CHAIN \"a04dd83b4c5e\""
},
{
"filename": "dm/gfx/nvn/hle_nvn.c",
@@ -1437,7 +1437,7 @@
},
{
"filename": "dm/gfx/nvn/dmsh_chain.h",
- "patch": "@@ lines that match nothing left out @@"
+ "patch": "-#define DMSH_CHAIN \"a04dd83b4c5e\"\n+#define DMSH_CHAIN \"7c03ff9e58ee\""
},
{
"filename": "dm/gfx/nvn/hle_nvn.c",
@@ -1567,7 +1567,7 @@
},
{
"filename": "dm/gfx/nvn/dmsh_chain.h",
- "patch": "@@ lines that match nothing left out @@"
+ "patch": "-#define DMSH_CHAIN \"7c03ff9e58ee\"\n+#define DMSH_CHAIN \"e68addf45840\""
},
{
"filename": "dm/gfx/nvn/hle_nvn.c",
@@ -1691,7 +1691,7 @@
},
{
"filename": "dm/gfx/nvn/dmsh_chain.h",
- "patch": "@@ lines that match nothing left out @@"
+ "patch": "-#define DMSH_CHAIN \"e68addf45840\"\n+#define DMSH_CHAIN \"2e793ae7a284\""
},
{
"filename": "dm/gfx/tools/dmsh_chain.lock",
@@ -1761,7 +1761,7 @@
},
{
"filename": "dm/gfx/nvn/dmsh_chain.h",
- "patch": "@@ lines that match nothing left out @@"
+ "patch": "-#define DMSH_CHAIN \"2e793ae7a284\"\n+#define DMSH_CHAIN \"826206e471c2\""
},
{
"filename": "dm/gfx/nvn/hle_nvn.c",
@@ -1951,7 +1951,7 @@
},
{
"filename": "dm/gfx/nvn/dmsh_chain.h",
- "patch": "@@ lines that match nothing left out @@"
+ "patch": "-#define DMSH_CHAIN \"826206e471c2\"\n+#define DMSH_CHAIN \"d0e99bd4b2fe\""
},
{
"filename": "dm/gfx/nvn/hle_nvn.c",
@@ -2113,7 +2113,7 @@
"files": [
{
"filename": "dm/gfx/nvn/dmsh_chain.h",
- "patch": "@@ lines that match nothing left out @@"
+ "patch": "-#define DMSH_CHAIN \"d0e99bd4b2fe\"\n+#define DMSH_CHAIN \"b7cd656abd7c\""
},
{
"filename": "dm/gfx/nvn/nvn_geometry.inc",
@@ -2350,18 +2350,54 @@
]
}
],
- "listed": [
- "105f417b",
+ "table1": [
+ [
+ "105f417b"
+ ],
+ [
+ "d76c45f7"
+ ],
+ [
+ "aea257b9"
+ ],
+ [
+ "cadd4be6"
+ ],
+ [
+ "8ef752a2"
+ ],
+ [
+ "f4bfc015"
+ ],
+ [
+ "68e8dc23"
+ ],
+ [
+ "8dd0c98a"
+ ],
+ [
+ "d3995ca4",
+ "a7bd05f4",
+ "fdb3710d",
+ "5251763d",
+ "c4b0618c",
+ "4de40e62",
+ "0e8503e7"
+ ],
+ [
+ "99947471"
+ ],
+ [
+ "cd859c38"
+ ]
+ ],
+ "table2": [
"c87bb116",
"4a1f6830",
- "d76c45f7",
- "aea257b9",
"ffdf67de",
- "cadd4be6",
"28035370",
"70ca6164",
"07fc83d4",
- "8ef752a2",
"9f74a1d6",
"d138ee87",
"5fd06dd1",
@@ -2371,24 +2407,12 @@
"c1df4dda",
"c0f34133",
"792df9fb",
- "f4bfc015",
"8482873b",
"94484212",
"5ce955ad",
- "68e8dc23",
"dad38db6",
- "8dd0c98a",
- "d3995ca4",
- "a7bd05f4",
- "fdb3710d",
- "5251763d",
- "c4b0618c",
- "4de40e62",
- "0e8503e7",
"a1b9a2ae",
- "99947471",
- "f634de70",
- "cd859c38"
+ "f634de70"
],
"not_listed": [
"ecc41fa8",
diff --git a/tools/tests/test_bump_candidates.py b/tools/tests/test_bump_candidates.py
index 433eb1f6..8013b43f 100644
--- a/tools/tests/test_bump_candidates.py
+++ b/tools/tests/test_bump_candidates.py
@@ -31,39 +31,66 @@ def commit(files, message='a change', sha='1' * 40):
def rows(c, **kw):
+ """The rows of the first table's kind: matched for a reason other than a patched file."""
+ return [r for r in B.find_candidates([c], ctx(**kw)) if r['likely']]
+
+
+def all_rows(c, **kw):
return B.find_candidates([c], ctx(**kw))
class V101Range(unittest.TestCase):
"""The reading of the 53 commits by hand (the v1.0.1 bump, #464) is the ground truth."""
def setUp(self):
- self.rows = {r['sha'][:8]: r for r in B.find_candidates(FIX['commits'], fixture_ctx())}
+ self.all = B.find_candidates(FIX['commits'], fixture_ctx())
+ self.rows = {r['sha'][:8]: r for r in self.all}
+ self.t1 = B.group_rows(self.all)
+ self.t1_shas = {s[:8] for g in self.t1 for s in g['shas']}
+ self.t2 = [r['sha'][:8] for r in self.all if not r['likely']]
def test_range_is_the_53_commits(self):
self.assertEqual(len(FIX['commits']), 53)
- def test_the_commits_found_by_hand_are_listed(self):
+ def test_the_commits_found_by_hand_are_in_the_first_table(self):
by_hand = {
'd76c45f7': 'chain and Xcode 27.2', 'd3995ca4': 'chain', 'a7bd05f4': 'chain', 'fdb3710d': 'chain', '5251763d': 'chain',
'c4b0618c': 'chain', '4de40e62': 'chain', '0e8503e7': 'chain',
'8ef752a2': 'NSP script, --title-id', '99947471': 'NSP script, folder input', '105f417b': 'DM_PSO_GPUS row, script',
'68e8dc23': 'pso_offline free-space text', 'cd859c38': 'RomFS.img entry layout',
- '70ca6164': 'fps cap (hle_nvn.c, hle_fpslock.c are patched)', '5fd06dd1': 'APFS text (hle_fs.c is patched)',
'cadd4be6': 'DM_PRESENT_LATENCY row', 'f4bfc015': 'DM_PRESENT_LATENCY row', 'aea257b9': 'DM_NVN_UNWRITTEN_DC row',
- '9f74a1d6': 'front_ios.m, main.m are patched', 'c1df4dda': 'front_mac.m is patched', 'c0f34133': 'front_mac.m',
- '8482873b': 'front_mac.m', 'a5281d01': 'raw HID pads (front_mac.m is patched)', 'dad38db6': 'Launcher.swift is patched',
- '8dd0c98a': 'Switch 2 bring-up',
+ '8dd0c98a': 'Switch 2 bring-up (pack_dump.py)',
}
for sha, why in by_hand.items():
- self.assertIn(sha, self.rows, f'{sha} ({why}) is missing')
+ self.assertIn(sha, self.t1_shas, f'{sha} ({why}) is not in table 1')
+
+ def test_the_hand_found_ones_that_only_hook_a_patched_file_are_in_the_second_table(self):
+ for sha in ('70ca6164', '5fd06dd1', '9f74a1d6', 'c1df4dda', 'c0f34133', '8482873b', 'a5281d01', 'dad38db6'):
+ self.assertIn(sha, self.t2, sha)
+ self.assertNotIn(sha, self.t1_shas, sha)
+
+ def test_a_commit_is_in_one_table_only(self):
+ self.assertFalse(self.t1_shas & set(self.t2))
+ self.assertEqual(len(self.t1_shas) + len(self.t2), len(self.all))
- def test_the_commits_with_no_dependency_are_not_listed(self):
+ def test_the_commits_with_no_dependency_are_in_neither_table(self):
for sha in ('d2a86b05', 'ba10db3d', '97f1514a', 'b99fca20', 'caac52fb', '588e01a5', '0e16e0e0', 'ecc41fa8', 'b8ffaf8b', '088429f4'):
self.assertNotIn(sha, self.rows, f'{sha} is listed')
- def test_the_list_is_the_fixture_s_own_ground_truth(self):
- self.assertEqual(sorted(self.rows), sorted(FIX['listed']))
- self.assertEqual(sorted(set(c['sha'][:8] for c in FIX['commits']) - set(self.rows)), sorted(FIX['not_listed']))
+ def test_the_split_is_the_fixture_s_own_ground_truth(self):
+ self.assertEqual([[s[:8] for s in g['shas']] for g in self.t1], FIX['table1'])
+ self.assertEqual(self.t2, FIX['table2'])
+ listed = self.t1_shas | set(self.t2)
+ self.assertEqual(sorted(set(c['sha'][:8] for c in FIX['commits']) - listed), sorted(FIX['not_listed']))
+ self.assertEqual((len(self.t1), len(self.t1_shas), len(self.t2)), (11, 17, 21))
+
+ def test_the_chain_moves_are_one_row_with_the_first_and_the_last_value(self):
+ g = next(g for g in self.t1 if len(g['shas']) > 1)
+ self.assertEqual([s[:8] for s in g['shas']], ['d3995ca4', 'a7bd05f4', 'fdb3710d', '5251763d', 'c4b0618c', '4de40e62', '0e8503e7'])
+ self.assertEqual(g['chain'], ('a7dbbce711c3', 'b7cd656abd7c'))
+ self.assertEqual(g['title'], 'Shader chain moves 7 times')
+ self.assertIn('from `a7dbbce711c3` to `b7cd656abd7c`', g['why'][0])
+ first = next(g for g in self.t1 if g['shas'] == [FIX['commits'][6]['sha']]) # d76c45f7, the Xcode pin: its own row (not consecutive)
+ self.assertEqual(first['chain'], ('e65a4ebd3322', 'a7dbbce711c3'))
def test_the_xcode_pin_row_names_the_chain_and_the_requirement(self):
why = '; '.join(self.rows['d76c45f7']['why'])
@@ -80,17 +107,24 @@ class V101Range(unittest.TestCase):
self.assertIn('the setting block', '; '.join(self.rows['8ef752a2']['why']))
def test_the_order_is_the_range_order(self):
- shas = [r['sha'][:8] for r in B.find_candidates(FIX['commits'], fixture_ctx())]
+ shas = [r['sha'][:8] for r in self.all]
order = [c['sha'][:8] for c in FIX['commits']]
self.assertEqual(shas, sorted(shas, key=order.index))
- def test_the_table(self):
- t = B.format_table(B.find_candidates(FIX['commits'], fixture_ctx()), FIX['old'], FIX['new'], 53)
- self.assertIn('## Candidate commits (38 of 53)', t)
+ def test_the_tables(self):
+ t = B.format_tables(self.all, FIX['old'], FIX['new'], 53)
self.assertIn('not a verdict', t)
+ self.assertIn('### Likely matters to the front ends (11 rows, 17 commits)', t)
self.assertIn('| Commit | Title | Files | Why | Handled |', t)
- self.assertEqual(len([l for l in t.splitlines() if l.startswith('| `')]), 38)
- self.assertTrue(all(l.endswith('| |') for l in t.splitlines() if l.startswith('| `')), 'the Handled column is empty')
+ first, second = t.split('<details>')
+ self.assertEqual(len([l for l in first.splitlines() if l.startswith('| ')]) - 1, 11)
+ self.assertTrue(all(l.endswith('| |') for l in first.splitlines() if l.startswith('| `')), 'the Handled column is empty')
+ self.assertIn('<summary>Touches files our patches change (21 commits)</summary>', second)
+ self.assertIn('already apply the patches and fail on a conflict', second)
+ self.assertEqual(len([l for l in second.splitlines() if l.startswith('| `')]), 21)
+ self.assertTrue(second.rstrip().endswith('</details>'))
+ for sha in self.t1_shas: self.assertNotIn(f'`{sha}`', second) # not repeated
+ self.assertIn('| `c87bb116` | Drain GPU completion temporaries on guest waiters (#818) | nvn_mtl.m (0008, 0053) |', second)
self.assertIn('https://github.com/seedds/nxnative/compare/bbc3b7378475...cd859c38a8f8', t)
@@ -162,9 +196,28 @@ class Rules(unittest.TestCase):
def test_patched_files_count_but_documents_tests_and_makefiles_do_not(self):
paths = {'dm/host/front_mac.m': ['0009', '0032'], 'docs/development.md': ['0005'], 'dm/host/tests/Makefile': ['0001']}
- got = rows(commit([('dm/host/front_mac.m', '')]), patch_paths=paths)
- self.assertEqual(got[0]['why'], ['files our patches change: front_mac.m (0009, 0032)'])
- self.assertEqual(rows(commit([('docs/development.md', ''), ('dm/host/tests/Makefile', '')]), patch_paths=paths), [])
+ got = all_rows(commit([('dm/host/front_mac.m', '')]), patch_paths=paths)
+ self.assertEqual(got[0]['patched'], ['front_mac.m (0009, 0032)'])
+ self.assertFalse(got[0]['likely']) # the second table only
+ self.assertEqual(rows(commit([('dm/host/front_mac.m', '')]), patch_paths=paths), [])
+ self.assertEqual(all_rows(commit([('docs/development.md', ''), ('dm/host/tests/Makefile', '')]), patch_paths=paths), [])
+
+ def test_a_commit_with_a_likely_reason_and_a_patched_file_is_one_row_of_the_first_table(self):
+ paths = {'dm/host/front_mac.m': ['0009']}
+ got = B.find_candidates([commit([('dm/host/front_mac.m', ''), ('docs/frontends.md', '')])], ctx(patch_paths=paths))
+ self.assertEqual(len(got), 1)
+ self.assertTrue(got[0]['likely'])
+ self.assertEqual(got[0]['files'], ['docs/frontends.md'])
+
+ def test_consecutive_chain_commits_group_and_others_break_the_run(self):
+ def chain(n, old, new, sha): return commit([('dm/gfx/nvn/dmsh_chain.h', f'-#define DMSH_CHAIN "{old}"\n+#define DMSH_CHAIN "{new}"')], sha=sha * 40)
+ cs = [chain(1, 'aaa111', 'bbb222', 'a'), chain(2, 'bbb222', 'ccc333', 'b'), commit([('docs/frontends.md', '')], sha='c' * 40), chain(3, 'ccc333', 'ddd444', 'd')]
+ g = B.group_rows(B.find_candidates(cs, ctx()))
+ self.assertEqual([len(x['shas']) for x in g], [2, 1, 1])
+ self.assertEqual(g[0]['chain'], ('aaa111', 'ccc333'))
+ self.assertEqual(g[0]['title'], 'Shader chain moves 2 times')
+ self.assertIn('from `ccc333` to `ddd444`', g[2]['why'][0])
+ self.assertEqual(B.group_rows(B.find_candidates([commit([('dm/gfx/tools/dmsh_chain.lock', '')])], ctx()))[0]['chain'], None) # a lock alone has no value to show
def test_patch_headers_are_read(self):
with tempfile.TemporaryDirectory() as t: