Skip to content
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 42 additions & 5 deletions scripts/tests/qwen-resolve-workflow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,24 @@ describe('qwen resolve workflow', () => {
'if [ "${TIMEOUT_EXPLICIT:-false}" != "true" ]; then',
);
expect(runStep).toContain('--json additions,deletions');
expect(runStep).toContain('if [ -n "$PR_SIZE_LINES" ]; then');
expect(runStep).toContain('if [ "$PR_SIZE_LINES" -le 300 ]; then');
expect(runStep).toContain('EFFECTIVE_TIMEOUT_MINUTES=180');
expect(runStep).toContain(
'EFFECTIVE_TIMEOUT_MINUTES="${{ vars.QWEN_REVIEW_MAX_TIMEOUT_MINUTES }}"',
);
// Slice the small-PR arm so a swap of the two assignments between the
// branches fails: unordered containment keeps both texts present.
const smallPrStart = runStep.indexOf(
'if [ "$PR_SIZE_LINES" -le 300 ]; then',
);
expect(smallPrStart).toBeGreaterThan(-1);
const smallPrArm = runStep.slice(
smallPrStart,
runStep.indexOf('else', smallPrStart),
);
expect(smallPrArm).toContain('EFFECTIVE_TIMEOUT_MINUTES=180');
expect(smallPrArm).not.toContain('vars.QWEN_REVIEW_MAX_TIMEOUT_MINUTES');
expect(runStep).not.toContain('EFFECTIVE_TIMEOUT_MINUTES=210');
expect(runStep).toContain(
'echo "effective_timeout_minutes=$EFFECTIVE_TIMEOUT_MINUTES"',
Expand All @@ -410,23 +423,43 @@ describe('qwen resolve workflow', () => {
'REASON="Qwen review timed out after ${attempt_timeout} seconds (of the ${QWEN_TIMEOUT}-minute budget)."',
);
expect(runStep).toContain('[ "$qwen_status" -eq 137 ]');
expect(fallbackStep).toContain('FAILURE_KIND:');
expect(fallbackStep).toContain('failure() &&');
expect(fallbackStep).toContain(
'FAILURE_KIND: "${{ steps.review.outputs.failure_kind || \'\' }}"',
);
expect(fallbackStep).toContain('TIMEOUT_MINUTES:');
expect(fallbackStep).toContain(
"TIMEOUT_MINUTES: '${{ steps.review.outputs.effective_timeout_minutes || steps.context.outputs.timeout_minutes }}'",
);
expect(fallbackStep).toContain(
'MAX_TIMEOUT_MINUTES="${{ vars.QWEN_REVIEW_MAX_TIMEOUT_MINUTES }}"',
);
expect(fallbackStep).toContain(
expect(fallbackStep).toContain('if [ "$FAILURE_KIND" = "timeout" ]; then');
// Slice the below-max arm so a transposition of the two bodies fails:
// unordered containment keeps both texts present in the wrong arms.
// Search for the else from the arm start so an unrelated earlier if/else
// in this step cannot invert the slice.
const belowMaxStart = fallbackStep.indexOf(
'if [ "$TIMEOUT_MINUTES" -lt "$MAX_TIMEOUT_MINUTES" ]; then',
);
expect(fallbackStep).toContain(
expect(belowMaxStart).toBeGreaterThan(-1);
const belowMaxArm = fallbackStep.slice(
belowMaxStart,
fallbackStep.indexOf('else', belowMaxStart),
);
expect(belowMaxArm).toContain(
'@qwen-code /review --timeout=${MAX_TIMEOUT_MINUTES}',
);
// The branch CONDITION, not just both branch bodies: with both bodies
// pinned as substrings, any comparison flip (-ge/-gt/-le) keeps both
// strings present and ships the wrong recovery advice on every timeout.
expect(fallbackStep).toContain(
'if [ "$TIMEOUT_MINUTES" -lt "$MAX_TIMEOUT_MINUTES" ]; then',
);
expect(fallbackStep).toContain(
'This run already used the maximum ${MAX_TIMEOUT_MINUTES} minute timeout.',
);
expect(fallbackStep).toContain('gh pr comment "$PR_NUMBER"');
expect(fallbackStep).toContain('**Qwen Code review timed out.**');
expect(fallbackStep).not.toContain(
'_Qwen Code review did not complete successfully:',
Expand Down Expand Up @@ -589,9 +622,13 @@ describe('qwen resolve workflow', () => {
expect(authorizeStep).toMatch(
/if \[ "\$PR_ACTION" = "review_requested" \]; then\s+principal="\$SENDER"/,
);
const reviewRequestedStart = authorizeStep.indexOf(
'if [ "$PR_ACTION" = "review_requested" ]; then',
);
expect(reviewRequestedStart).toBeGreaterThan(-1);
const reviewRequestedBranch = authorizeStep.slice(
authorizeStep.indexOf('if [ "$PR_ACTION" = "review_requested" ]; then'),
authorizeStep.indexOf('else'),
reviewRequestedStart,
authorizeStep.indexOf('else', reviewRequestedStart),
);
expect(reviewRequestedBranch).toContain('principal="$SENDER"');
expect(reviewRequestedBranch).not.toContain(
Expand Down
Loading