Skip to content

fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op - #74

Open
hyperpolymath wants to merge 1 commit into
mainfrom
fix/find-exec-terminator
Open

fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op#74
hyperpolymath wants to merge 1 commit into
mainfrom
fix/find-exec-terminator

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

tests/e2e/template_instantiation_test.sh ran find … -exec bash -c '…' _ "\$file", which has two defects on one line:

  1. No ; or + terminator — the file does not parse (SC2067).
  2. "\$file" where {} belongs\$file is assigned only inside the -exec body, so in the outer scope it is unset. \$1 arrived empty, file="", and every grep/sed operated on an empty path.

The consequence is worse than a lint error. The placeholder-replacement step silently did nothing, then logged "All placeholder tokens replaced". A test whose entire purpose is to prove instantiation worked was passing without replacing a single token — a plausible cause of estate repos shipping with literal {{project}} still in their sources.

Corrected to ' _ {} \; so find passes each matched path.

Found by an estate-wide sweep of 5,111 scripts across 375 repos: this identical stale copy exists in 30 repositories. rsr-template-repo's own copy is already correct and restructured (371 lines vs the 268 here), so these are stale duplicates that never picked up the upstream fix.

…as a no-op

tests/e2e/template_instantiation_test.sh ran:

    find ... -exec bash -c '
        file="$1"
        ... grep/sed over $file ...
    ' _ "$file"

Two defects in that one line:

  1. No ';' or '+' terminator, so the file does not parse (SC2067).
  2. "$file" is passed where {} belongs. $file is assigned ONLY inside the
     -exec body, so in the outer scope it is UNSET — $1 arrived empty, file=""
     and every grep/sed operated on an empty path.

⚠ The consequence is worse than a lint error: the placeholder-replacement step
SILENTLY DID NOTHING, then logged "All placeholder tokens replaced". A test
whose whole purpose is to prove instantiation worked was passing without
replacing a single token. That is a plausible cause of estate repos shipping
with literal {{project}} tokens still in their sources.

Corrected to "' _ {} \;" so find passes each matched path.

Found by an estate-wide shellcheck sweep of 5,111 scripts across 375 repos:
this identical stale copy exists in 30 repositories. rsr-template-repo's own
copy is already correct and restructured (371 lines vs the 268 here), so these
are stale duplicates that never picked up the upstream fix.
@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 367e2a2b-e75b-44b5-9985-920e841a6f8d

📥 Commits

Reviewing files that changed from the base of the PR and between 7f0cdd1 and 8d5fe66.

📒 Files selected for processing (1)
  • tests/e2e/template_instantiation_test.sh

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (1)
tests/e2e/template_instantiation_test.sh (1)

140-140: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Fixed template instantiation tests so placeholder replacement processes the intended files correctly.
    • Improved test command handling to ensure the operation completes reliably.

Walkthrough

The template instantiation end-to-end test now passes each matched file to the placeholder replacement command and correctly terminates the find -exec expression.

Changes

Template instantiation test

Layer / File(s) Summary
Placeholder replacement invocation
tests/e2e/template_instantiation_test.sh
The find -exec bash -c command now uses {} as the file argument and includes the command terminator.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 8d5fe

This localized test-script fix is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

Poem

A rabbit checks each template file,
The braces guide it down the aisle.
The command now ends just right,
Placeholders hop into sight,
And tests finish with a smile.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description clearly explains the defect, impact, correction, and discovery context. However, it does not follow the repository template because it omits the Changes, RSR Quality Checklist, `Te… Add the required template sections. List the change under Changes, complete the RSR Quality Checklist, describe the test command and result under Testing, and add screenshots or terminal output if applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the test fix: it terminates the find -exec command and passes {}. It is concise and directly related to the change.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

Full details: Description check

Explanation

The description clearly explains the defect, impact, correction, and discovery context. However, it does not follow the repository template because it omits the Changes, RSR Quality Checklist, Testing, and Screenshots sections.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gitar-bot

gitar-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

While this PR correctly identifies and fixes the syntax error preventing the 'find -exec' command from executing, the current implementation remains non-functional due to subshell scope limitations.

There are two primary concerns: the subshell cannot access the local 'TEST_*' variables defined in the parent script, and the filename passed via '{}' is not assigned to the '$file' variable used in the command string. These issues result in a continued 'no-op' state where no placeholders are actually replaced. These logic errors should be addressed to fulfill the intent of the fix.

1 comment outside of the diff
tests/e2e/template_instantiation_test.sh

line 21-32 🟡 MEDIUM RISK
Suggestion: The variables TEST_OWNER, TEST_FORGE, TEST_AUTHOR_EMAIL, TEST_DESCRIPTION, TEST_PRIMARY_LANGUAGE, and YELLOW are assigned but never used. Since this PR fixes the find -exec sub-shell logic used for placeholder replacement, ensure these variables are exported or passed as arguments if they are intended to be accessed within that sub-shell.

Suggested prompt for your agent:

Review the script to see if the unused TEST_* variables should be exported for use in the find -exec sub-shell or passed as arguments to ensure placeholder replacement works correctly.

Test suggestions

  • Verify that placeholders (e.g., {{project}}) are actually replaced in generated files during template instantiation.

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

@@ -137,7 +137,7 @@ find "$TEST_REPO_PATH" -type f \
sed -i "s|$placeholder|$value|g" "$file"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH RISK

The subshell script refers to "$file" which is likely unset in this scope. Since find passes the filename as the first positional parameter, you should assign file="$1" at the start of the sh -c block or use "$1" directly.

Suggested prompt for your agent:

In tests/e2e/template_instantiation_test.sh, find the find ... -exec sh -c block and ensure that file="$1" is assigned at the beginning of the subshell script so that subsequent sed and grep commands use the correct filename matched by find.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant