Better coloring of output of Rake tasks; Turn off colored output in Rake tasks if not on a TTY (not sure if it works in Hudson); Add support to TCR for turning off colors since there is code to calc options but it wasn't used; NOTE: coloring in TCR should be MUCH better tested.

This commit is contained in:
Davis W. Frank
2011-06-16 22:34:11 -07:00
parent 75dd391d57
commit 0b97951766
10 changed files with 45 additions and 77 deletions

View File

@@ -1,6 +1,6 @@
desc "Build core jasmine.js"
task :build_dist => [:lint, :write_version_file] do
puts 'Building Jasmine distribution from source'
puts 'Building Jasmine distribution from source'.cyan
concat_into('lib/jasmine.js') { core_sources + version_source_file }
concat_into('lib/jasmine-html.js') { html_sources }
@@ -19,7 +19,7 @@ end
desc 'Check jasmine sources for coding problems'
task :lint do
puts "Running JSHint via Node.js"
puts "Running JSHint via Node.js".cyan
system("node jshint/run.js") || exit(1)
end

View File

@@ -3,13 +3,15 @@ task :spec => ["build_dist", "count_specs", "spec:node", "spec:browser"]
desc 'Run specs in Node.js'
task "spec:node" => [:count_specs, :require_node] do
puts "Running all appropriate specs via Node.js"
system("node spec/node_suite.js")
puts "Running all appropriate specs via Node.js".cyan
color = Term::ANSIColor.coloring? ? "--color" : "--noColor"
system("node spec/node_suite.js #{color}")
end
desc "Run specs in the default browser (MacOS only)"
task "spec:browser" => [:count_specs, :build_runner_html] do
puts "Running all appropriate specs via the default web browser"
puts "Running all appropriate specs via the default web browser".cyan
system("open spec/runner.html")
end
@@ -20,8 +22,8 @@ task :count_specs do
html_spec_count = count_specs_in(Dir.glob('spec/html/*.js'))
puts "\n"
puts "#{yellow(core_specs_count + console_spec_count)} specs for Node.js runner (exclude DOM-related specs)"
puts "#{yellow(core_specs_count + console_spec_count + html_spec_count)} specs for Browser runner (all specs)"
puts "#{(core_specs_count + console_spec_count).to_s.yellow.bold} specs for Node.js runner (exclude DOM-related specs)"
puts "#{(core_specs_count + console_spec_count + html_spec_count).to_s.yellow.bold} specs for Browser runner (all specs)"
puts "\n"
puts "Please verify that these numbers match the runner output."
puts "\n"
@@ -33,7 +35,3 @@ def count_specs_in(files)
count
end
end
def yellow(str)
"\033[33m#{str}\033[0m"
end