-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try to fix failures related to changes in Thor 1.3.0 #913
Conversation
Summary
This summary was generated using OpenAI's gpt-4 with a temperature of 0.5. 🧵 Slack Thread
David Stosik archived this conversation from |
@@ -3,6 +3,9 @@ | |||
# Configure Rails Environment | |||
ENV["RAILS_ENV"] = "test" | |||
|
|||
# Don't wrap output in tests | |||
ENV["THOR_COLUMNS"] = "200" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed this had the expected consequence for both Thor 1.2.2 and Thor 1.3.0:
require "thor/version"
puts Thor::VERSION
if Thor::VERSION >= "1.3.0"
assert_equal 200, Thor::Shell::Terminal.terminal_width
else
assert_equal 200, Thor::Base.shell.new.terminal_width
end
Unfortunately, the output is still wrapped when using Thor 1.3.0:
Failure:
MaintenanceTasks::CLITest#test_`help_perform`_loads_all_tasks_and_displays_them [test/lib/maintenance_tasks/cli_test.rb:104]:
In stdout.
Expected /\ \ `maintenance_tasks\ perform`\ will\ run\ the\ Maintenance\ Task\ specified\ by\ the\ \[TASK\ NAME\]\ argument\.\n\n\ \ Available\ Tasks:\n\n\ \ Task1\n\n\ \ Task2\n/ to match "Usage:\n cli_test.rb perform [TASK NAME]\n\nOptions:\n [--csv=CSV] # Supply a CSV file to be processed by a CSV Task, --csv path/to/csv/file.csv\n [--arguments=key:value] # Supply arguments for a Task that accepts parameters as a set of <key>:<value> pairs.\n\nDescription:\n`maintenance_tasks perform` will run the Maintenance Task specified by\nthe [TASK NAME] argument.\n\nAvailable Tasks:\n\nTask1\n\nTask2\n".
Cleaning up, we have:
Failure:
MaintenanceTasks::CLITest#test_`help_perform`_loads_all_tasks_and_displays_them [test/lib/maintenance_tasks/cli_test.rb:104]:
In stdout.
Expected /
`maintenance_tasks perform` will run the Maintenance Task specified by the [TASK NAME] argument.
Available Tasks:
Task1
Task2
/ to match "
Usage:
cli_test.rb perform [TASK NAME]
Options:
[--csv=CSV] # Supply a CSV file to be processed by a CSV Task, --csv path/to/csv/file.csv
[--arguments=key:value] # Supply arguments for a Task that accepts parameters as a set of <key>:<value> pairs.
Description:
`maintenance_tasks perform` will run the Maintenance Task specified by
the [TASK NAME] argument.
Available Tasks:
Task1
Task2
".
- Thor CLI output was cut after
specified by
(70 characters), even thoughThor::Shell::Terminal.terminal_width
returns 200. - The Thor CLI output also seems to be missing indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed the CLI output changed:
Before
Usage:
maintenance_tasks perform [TASK NAME]
Options:
[--csv=CSV] # Supply a CSV file to be processed by a CSV Task, --csv path/to/csv/file.csv
[--arguments=key:value] # Supply arguments for a Task that accepts parameters as a set of <key>:<value> pairs.
Description:
`maintenance_tasks perform` will run the Maintenance Task specified by the [TASK NAME] argument.
Available Tasks:
Maintenance::BatchImportPostsTask
Maintenance::CallbackTestTask
etc...
After
cd test/dummy && ../../exe/maintenance_tasks help perform
Usage:
maintenance_tasks perform [TASK NAME]
Options:
[--csv=CSV] # Supply a CSV file to be processed by a CSV Task, --csv path/to/csv/file.csv
[--arguments=key:value] # Supply arguments for a Task that accepts parameters as a set of <key>:<value> pairs.
Description:
`maintenance_tasks perform` will run the Maintenance Task specified by
the [TASK NAME] argument.
Available Tasks:
Maintenance::BatchImportPostsTask
Maintenance::CallbackTestTask
etc...
The description is now cut at 70 at not indented.
677badc
to
e517c4c
Compare
lib/maintenance_tasks/cli.rb
Outdated
@@ -56,6 +56,8 @@ def perform(name) | |||
LONGDESC | |||
end | |||
|
|||
commands["perform"].wrap_long_description = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures newer versions of Thor (>= 1.3.0, including rails/thor#739) will wrap and indent the long description as older versions used to.
It fixes the problem I'm describing in this other comment thread.
e517c4c
to
8cc0fe6
Compare
Update: please take a look at this alternative: #914. I think it's a better approach to the issue.
The release of Thor 1.3.0 introduced issues related to:
#terminal_width
method moved) (Extract print methods to seperate classes rails/thor#854)This PR should allow tests to pass whether Thor's version is before or after these changes: