test: validate ANSI escape codes are not in redirected composer output#74
Conversation
Adds a test to verify that `lando composer` output does not contain ANSI escape codes when stdout is redirected to a file. This test is expected to FAIL until the fix is applied (removing `--ansi` from the composer tooling command). Ref lando/drupal#157
✅ Deploy Preview for lando-joomla ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Missing blank line between test sections breaks formatting
- Added the missing blank line between the command on line 45 and the comment on line 47 to match the consistent formatting pattern used throughout the file.
Or push these changes by commenting:
@cursor push 81d009f66f
Preview (81d009f66f)
diff --git a/examples/joomla-defaults/README.md b/examples/joomla-defaults/README.md
--- a/examples/joomla-defaults/README.md
+++ b/examples/joomla-defaults/README.md
@@ -43,6 +43,7 @@
# Should not include ANSI escape codes when output is redirected
lando composer --version > /tmp/composer-output.txt 2>&1 && ! grep -P '\x1b\[' /tmp/composer-output.txt
+
# Should use the correct default config files
lando exec appserver -- cat /usr/local/etc/php/conf.d/zzz-lando-my-custom.ini | grep "; LANDOJOOMLAPHPINI"
lando exec appserver -- curl -L http://localhost/info.php | grep max_execution_time | grep 91| lando exec appserver -- /bin/sh -c 'NO_COLOR=1 composer -V' | grep "Composer version 2." | ||
|
|
||
| # Should not include ANSI escape codes when output is redirected | ||
| lando composer --version > /tmp/composer-output.txt 2>&1 && ! grep -P '\x1b\[' /tmp/composer-output.txt |
There was a problem hiding this comment.
Missing blank line between test sections breaks formatting
Low Severity
Every other test section in this file (and in sibling example READMEs like joomla-custom/README.md) has a blank line separating the command from the next # comment block. The new test on line 45 is immediately followed by the next section's comment on line 46 without an intervening blank line, breaking the file's consistent formatting pattern. Since leia parses these README code blocks to generate tests, inconsistent structure could affect readability or future parsing behavior.
Composer auto-detects TTY and enables color output when appropriate. The --ansi flag forced ANSI escape codes even when stdout was redirected to a file or used in command substitution, breaking scripted usage. Ref lando/drupal#157




Adds a test that verifies
lando composer --version > file.txtdoes not contain ANSI escape codes in the output file.This test is expected to FAIL on CI until the fix is applied — removing
--ansifrom the composer tooling command.The root cause is
--ansibeing hardcoded in the composer tooling definition. Composer auto-detects TTY when--ansiisn't forced.Ref lando/drupal#157
Note
Low Risk
Low risk: a small change to the default
composertooling command plus an example verification check; the main risk is any downstream reliance on forced ANSI formatting in composer output.Overview
Stops forcing ANSI output for the default
composertooling by removing the hardcoded--ansiflag, so redirected output (eglando composer --version > file) no longer contains escape codes.Adds an example verification command to assert redirected composer output is free of ANSI escape sequences, and notes the change in the unreleased changelog.
Written by Cursor Bugbot for commit 8ad500c. This will update automatically on new commits. Configure here.