Permalink
Browse files

Updating based on feedback from Jim regarding Emacs command window no…

…t being a tty. Also adding some help/instructions about the sessions gem required for running all the tests.
  • Loading branch information...
Gavin Stark
Gavin Stark committed Aug 11, 2008
1 parent fba0457 commit f8a729ba046b34bed5551327460fece4617e2cb0
Showing with 20 additions and 7 deletions.
  1. +1 −0 README
  2. +7 −1 lib/rake.rb
  3. +1 −1 test/functional.rb
  4. +11 −5 test/test_application.rb
View
1 README
@@ -46,6 +46,7 @@ Download and install rake with the following.
If you wish to run the unit and functional tests that come with Rake:
+* Install the 'session' gem in order to run the functional tests.
* CD into the top project directory of rake.
* Type one of the following:
View
@@ -2002,6 +2002,12 @@ def tty_output=( tty_output_state )
@tty_output = tty_output_state
end
+ # We will truncate output if we are outputting to a TTY or if we've been
+ # given an explicit column width to honor
+ def truncate_output?
+ tty_output? || ENV['RAKE_COLUMNS']
+ end
+
# Display the tasks and dependencies.
def display_tasks_and_comments
displayable_tasks = tasks.select { |t|
@@ -2017,7 +2023,7 @@ def display_tasks_and_comments
end
else
width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
- max_column = tty_output? ? terminal_width - name.size - width - 7 : nil
+ max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil
displayable_tasks.each do |t|
printf "#{name} %-#{width}s # %s\n",
t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
View
@@ -6,7 +6,7 @@
require 'session'
rescue LoadError
puts "UNABLE TO RUN FUNCTIONAL TESTS"
- puts "No Session Found"
+ puts "No Session Found (gem install session)"
end
if defined?(Session)
View
@@ -65,8 +65,6 @@ def test_display_tasks_with_task_name_wider_than_tty_display
end
def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment
-
- ENV['RAKE_COLUMNS'] = '80'
@app.options.show_task_pattern = //
@app.tty_output = false
description = "something short"
@@ -76,19 +74,27 @@ def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comm
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
# Ensure the entire task name is output and we end up showing no description
assert_match(/rake #{task_name} # #{description}/, out)
- ensure
- ENV['RAKE_COLUMNS'] = nil
end
def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment
- ENV['RAKE_COLUMNS'] = '80'
@app.options.show_task_pattern = //
@app.tty_output = false
@app.last_description = "1234567890" * 8
@app.define_task(Rake::Task, "t")
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
assert_match(/^rake t/, out)
assert_match(/# #{@app.last_description}/, out)
+ end
+
+ def test_display_tasks_with_long_comments_to_a_non_tty_with_columns_set_truncates_comments
+ ENV['RAKE_COLUMNS'] = '80'
+ @app.options.show_task_pattern = //
+ @app.tty_output = false
+ @app.last_description = "1234567890" * 8
+ @app.define_task(Rake::Task, "t")
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
+ assert_match(/^rake t/, out)
+ assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
ensure
ENV['RAKE_COLUMNS'] = nil
end

0 comments on commit f8a729b

Please sign in to comment.