Skip to content

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

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#41
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.
@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: 93f5571e-baa3-4cad-adaa-337c6ff3cfd3

📥 Commits

Reviewing files that changed from the base of the PR and between 7523415 and 05c4a5b.

📒 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. (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Gitar
🔇 Additional comments (1)
tests/e2e/template_instantiation_test.sh (1)

140-140: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved template instantiation checks to ensure placeholder replacement commands consistently reference the correct files.
    • This increases the reliability of automated template generation and helps prevent incorrect substitutions during project setup.

Walkthrough

The end-to-end template instantiation test now passes each matched file path from find to the shell command through {}.

Changes

Template path handling

Layer / File(s) Summary
Pass matched paths to the test command
tests/e2e/template_instantiation_test.sh
The find -exec bash -c invocation now supplies each matched path through {} instead of "$file".

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

Merge Risk: ⚪ Minimal · up to 05c4a

This is a localized test-script correction with no actionable merge-blocking risk remaining beyond normal checks and review.

Poem

A rabbit found a path in the nest
{} carried each file to the test
No literal string stayed
The command was obeyed
And templates now hop at their best

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the defect, its impact, and the correction. However, it does not follow the repository template and omits the required Summary, Changes, RSR Quality Checklist, Testing, and Sc… Reformat the description to use the repository template. Add the required sections, complete the applicable checklist items, and state the commands or other tests used to verify the change.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: it fixes the unterminated find -exec command and passes {} to the placeholder replacement step.
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.
Full details: Description check

Explanation

The description explains the defect, its impact, and the correction. However, it does not follow the repository template and omits the required Summary, Changes, RSR Quality Checklist, Testing, and Screenshots sections.

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.

  • 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.

@sonarqubecloud

Copy link
Copy Markdown

@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

This PR addresses the immediate syntax errors in the find -exec command (missing terminator and placeholder), but the logic for template substitution remains a no-op.

A critical issue was identified where the use of single quotes for the sh -c subshell prevents the shell from expanding the $placeholder, $value, and $file variables. Consequently, the sed and grep operations will not perform any actual substitutions.

Additionally, several variables intended for template metadata (like TEST_OWNER and TEST_AUTHOR_EMAIL) are defined but unused, which correlates with the lack of verification in the current test suite. These issues should be resolved to ensure the E2E test provides meaningful coverage.

About this PR

  • The PR fixes the command execution syntax but does not yet fulfill the intent of the E2E test. There is currently no verification logic to ensure that placeholders (e.g., {{project}}) are actually replaced with the expected values in the output files. Please ensure the test asserts the content of the instantiated templates.
1 comment outside of the diff
tests/e2e/template_instantiation_test.sh

line 21-32198 🟡 MEDIUM RISK
Several test configuration variables (TEST_OWNER, TEST_FORGE, TEST_AUTHOR_EMAIL, TEST_DESCRIPTION, TEST_PRIMARY_LANGUAGE) and the YELLOW color constant are defined but never used. These should likely be used as the values for template substitution or within the test reporting logic.

Test suggestions

  • Verify that template placeholders (e.g., {{project}}) are actually replaced with provided values in the instantiated files.
  • Ensure the find command correctly identifies all files requiring substitution within the target directory.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify that template placeholders (e.g., {{project}}) are actually replaced with provided values in the instantiated files.
2. Ensure the find command correctly identifies all files requiring substitution within the target directory.

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

fi
done
' _ "$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 variables $placeholder, $value, and $file used in the sh -c block will not be expanded because the command string is single-quoted. Additionally, the file found by find is passed as the first argument ($1); you must either assign it (e.g., file="$1") or use $1 directly in the sed command.

Try running the following prompt in your coding agent:

In tests/e2e/template_instantiation_test.sh, fix the find -exec command so that shell variables for placeholders and values are correctly passed into the subshell (e.g., as arguments $2, $3) and the file path from {} is correctly mapped to the variable used in the sed command.

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