@@ -5738,6 +5738,10 @@ def test_baseline_promotion_rejects_head_status_policy_mutations(self):
57385738 "the latest head parity status only (verify is advisory)")
57395739 for predicate in (verify + ' and ' + parity, parity + ' and ' + verify,
57405740 parity + '\n and ' + verify,
5741+ '(' + parity, parity + ')', '((' + parity + ')',
5742+ '(' + parity + '))', '(' + parity + ') or true',
5743+ '(' + parity + ') and true', 'not (' + parity + ')',
5744+ '(' + parity + ') | true',
57415745 verify, 'true', '.["pineforge/parity"] == "failure"'):
57425746 with self.subTest(predicate=predicate):
57435747 changed = original.copy()
@@ -5746,6 +5750,37 @@ def test_baseline_promotion_rejects_head_status_policy_mutations(self):
57465750 self.assertNotEqual(changed[2], original[2])
57475751 self.assertIn(finding, ci_workflow_findings(*changed))
57485752
5753+ def test_baseline_promotion_head_predicate_four_rows_and_wrapping(self):
5754+ original = self.ci_sources()
5755+ self.assertEqual(ci_workflow_findings(*original), [])
5756+ parity = '.["pineforge/parity"] == "success"'
5757+ finding = ("baseline promotion must run main's copy and require "
5758+ "the latest head parity status only (verify is advisory)")
5759+ cases = (
5760+ ('parenthesized-parity-only',
5761+ '(.["pineforge/parity"] == "success")', []),
5762+ ('neither-required', 'true', [finding]),
5763+ ('parenthesized-verify-and-parity',
5764+ '(.["pineforge/verify"] == "success" and .["pineforge/parity"] == "success")',
5765+ [finding]),
5766+ ('verify-only', '.["pineforge/verify"] == "success"', [finding]),
5767+ )
5768+ for name, predicate, expected in cases:
5769+ with self.subTest(policy=name):
5770+ changed = original.copy()
5771+ changed[2] = in_step(changed[2], 'promote', 'Confirm the gate on the PR head',
5772+ parity, predicate)
5773+ self.assertNotEqual(changed[2], original[2])
5774+ self.assertEqual(ci_workflow_findings(*changed), expected)
5775+ for predicate in (' ' + parity + ' ', '( ( ' + parity + ' ) )',
5776+ '(\n ( ' + parity + ' )\n )'):
5777+ with self.subTest(wrapping=predicate):
5778+ changed = original.copy()
5779+ changed[2] = in_step(changed[2], 'promote', 'Confirm the gate on the PR head',
5780+ parity, predicate)
5781+ self.assertNotEqual(changed[2], original[2])
5782+ self.assertEqual(ci_workflow_findings(*changed), [])
5783+
57495784 def test_promotion_guard_rejects_added_contents_read_permission(self):
57505785 finding = 'baseline promotion must start with the pinned read-only promote-guard'
57515786 findings = self.mutated_file_findings(
0 commit comments