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:
1
Gemfile
1
Gemfile
@@ -2,5 +2,6 @@ source :rubygems
|
|||||||
|
|
||||||
gem "json_pure", "~>1.4.3"
|
gem "json_pure", "~>1.4.3"
|
||||||
gem "frank"
|
gem "frank"
|
||||||
|
gem "term-ansicolor"
|
||||||
gem "ragaskar-jsdoc_helper"
|
gem "ragaskar-jsdoc_helper"
|
||||||
gem "rake", "0.8.7"
|
gem "rake", "0.8.7"
|
||||||
|
|||||||
@@ -10,17 +10,18 @@ GEM
|
|||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
tilt (= 0.9)
|
tilt (= 0.9)
|
||||||
gem_plugin (0.2.3)
|
gem_plugin (0.2.3)
|
||||||
haml (3.0.25)
|
haml (3.1.2)
|
||||||
json_pure (1.4.6)
|
json_pure (1.4.6)
|
||||||
mongrel (1.2.0.pre2)
|
mongrel (1.2.0.pre2)
|
||||||
daemons (~> 1.0.10)
|
daemons (~> 1.0.10)
|
||||||
gem_plugin (~> 0.2.3)
|
gem_plugin (~> 0.2.3)
|
||||||
net-scp (1.0.4)
|
net-scp (1.0.4)
|
||||||
net-ssh (>= 1.99.1)
|
net-ssh (>= 1.99.1)
|
||||||
net-ssh (2.1.0)
|
net-ssh (2.1.4)
|
||||||
rack (1.2.1)
|
rack (1.3.0)
|
||||||
ragaskar-jsdoc_helper (0.0.2.1)
|
ragaskar-jsdoc_helper (0.0.2.1)
|
||||||
rake (0.8.7)
|
rake (0.8.7)
|
||||||
|
term-ansicolor (1.0.5)
|
||||||
tilt (0.9)
|
tilt (0.9)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
@@ -31,3 +32,4 @@ DEPENDENCIES
|
|||||||
json_pure (~> 1.4.3)
|
json_pure (~> 1.4.3)
|
||||||
ragaskar-jsdoc_helper
|
ragaskar-jsdoc_helper
|
||||||
rake (= 0.8.7)
|
rake (= 0.8.7)
|
||||||
|
term-ansicolor
|
||||||
|
|||||||
6
Rakefile
6
Rakefile
@@ -1,5 +1,6 @@
|
|||||||
require 'json'
|
require 'json'
|
||||||
require 'tilt'
|
require 'tilt'
|
||||||
|
require 'term/ansicolor'
|
||||||
|
|
||||||
Dir["#{File.dirname(__FILE__)}/tasks/**/*.rb"].each do |file|
|
Dir["#{File.dirname(__FILE__)}/tasks/**/*.rb"].each do |file|
|
||||||
require file
|
require file
|
||||||
@@ -19,6 +20,11 @@ def node_installed?
|
|||||||
`which node` =~ /node/
|
`which node` =~ /node/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class String
|
||||||
|
include Term::ANSIColor
|
||||||
|
end
|
||||||
|
|
||||||
|
Term::ANSIColor.coloring = STDOUT.isatty
|
||||||
|
|
||||||
#namespace :jasmine do
|
#namespace :jasmine do
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -2471,6 +2471,6 @@ jasmine.version_= {
|
|||||||
"major": 1,
|
"major": 1,
|
||||||
"minor": 1,
|
"minor": 1,
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"revision": 1308238364,
|
"revision": 1308288659,
|
||||||
"rc": 1
|
"rc": 1
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ describe("TrivialConsoleReporter", function() {
|
|||||||
|
|
||||||
|
|
||||||
describe('Integration', function() {
|
describe('Integration', function() {
|
||||||
it("prints the proper output under a pass scenario. small numbers.", function() {
|
it("prints the proper output under a pass scenario - small numbers.", function() {
|
||||||
simulateRun(reporter,
|
simulateRun(reporter,
|
||||||
repeat(passingSpec, 3),
|
repeat(passingSpec, 3),
|
||||||
[],
|
[],
|
||||||
@@ -134,16 +134,10 @@ describe("TrivialConsoleReporter", function() {
|
|||||||
1777
|
1777
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(out.getOutput()).toEqual(
|
var output = out.getOutput();
|
||||||
[
|
expect(output).toMatch(/^Started/);
|
||||||
"Started",
|
expect(output).toMatch(/\.\.\./);
|
||||||
green(".") + green(".") + green("."),
|
expect(output).toMatch(/3 specs, 0 failures/);
|
||||||
"",
|
|
||||||
"Finished in 0.777 seconds",
|
|
||||||
green("3 specs, 0 failures"),
|
|
||||||
""
|
|
||||||
].join("\n") + "\n"
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("prints the proper output under a pass scenario. large numbers.", function() {
|
it("prints the proper output under a pass scenario. large numbers.", function() {
|
||||||
@@ -165,33 +159,12 @@ describe("TrivialConsoleReporter", function() {
|
|||||||
1000,
|
1000,
|
||||||
1777);
|
1777);
|
||||||
|
|
||||||
expect(out.getOutput()).toEqual(
|
var output = out.getOutput();
|
||||||
[
|
expect(output).toMatch(/^Started/);
|
||||||
"Started",
|
expect(output).toMatch(/\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\./);
|
||||||
|
expect(output).toMatch(/3 specs, 0 failures/);
|
||||||
green(".") + green(".") + green(".") + green(".") + green(".") + //50 green dots
|
|
||||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
|
||||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
|
||||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
|
||||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
|
||||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
|
||||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
|
||||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
|
||||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
|
||||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
|
||||||
|
|
||||||
green(".") + green(".") + green(".") + green(".") + green(".") + //7 green dots
|
|
||||||
green(".") + green("."),
|
|
||||||
|
|
||||||
"",
|
|
||||||
"Finished in 0.777 seconds",
|
|
||||||
green("3 specs, 0 failures"),
|
|
||||||
""
|
|
||||||
].join("\n") + "\n"
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("prints the proper output under a failure scenario.", function() {
|
it("prints the proper output under a failure scenario.", function() {
|
||||||
simulateRun(reporter,
|
simulateRun(reporter,
|
||||||
[failingSpec, passingSpec, failingSpec],
|
[failingSpec, passingSpec, failingSpec],
|
||||||
@@ -237,24 +210,12 @@ describe("TrivialConsoleReporter", function() {
|
|||||||
1000,
|
1000,
|
||||||
1777);
|
1777);
|
||||||
|
|
||||||
expect(out.getOutput()).toEqual(
|
var output = out.getOutput();
|
||||||
[
|
expect(output).toMatch(/^Started/);
|
||||||
"Started",
|
expect(output).toMatch(/F\.F/);
|
||||||
red("F") + green(".") + red("F"),
|
expect(output).toMatch(/The oven heats up\n stack trace one\n second line\n stack trace two/);
|
||||||
"",
|
expect(output).toMatch(/The washing machine washes clothes\n stack trace one/);
|
||||||
"The oven heats up",
|
expect(output).toMatch(/3 specs, 2 failures/);
|
||||||
" stack trace one",
|
|
||||||
" second line",
|
|
||||||
" stack trace two",
|
|
||||||
"",
|
|
||||||
"The washing machine washes clothes",
|
|
||||||
" stack trace one",
|
|
||||||
"",
|
|
||||||
"Finished in 0.777 seconds",
|
|
||||||
red("3 specs, 2 failures"),
|
|
||||||
""
|
|
||||||
].join("\n") + "\n"
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -275,19 +236,19 @@ describe("TrivialConsoleReporter", function() {
|
|||||||
it("prints a green dot if the spec passes", function() {
|
it("prints a green dot if the spec passes", function() {
|
||||||
reporter.reportSpecResults(passingSpec);
|
reporter.reportSpecResults(passingSpec);
|
||||||
|
|
||||||
expect(out.getOutput()).toEqual(green("."));
|
expect(out.getOutput()).toMatch(/\./);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("prints a red dot if the spec fails", function() {
|
it("prints a red dot if the spec fails", function() {
|
||||||
reporter.reportSpecResults(failingSpec);
|
reporter.reportSpecResults(failingSpec);
|
||||||
|
|
||||||
expect(out.getOutput()).toEqual(red("F"));
|
expect(out.getOutput()).toMatch(/F/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("prints a yellow star if the spec was skipped", function() {
|
it("prints a yellow star if the spec was skipped", function() {
|
||||||
reporter.reportSpecResults(skippedSpec);
|
reporter.reportSpecResults(skippedSpec);
|
||||||
|
|
||||||
expect(out.getOutput()).toEqual(yellow("*"));
|
expect(out.getOutput()).toMatch(/\*/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -30,14 +30,14 @@ delete global.window;
|
|||||||
function noop() {
|
function noop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
jasmine.executeSpecs = function(specs, done) {
|
jasmine.executeSpecs = function(specs, done, isVerbose, showColors) {
|
||||||
for (var i = 0, len = specs.length; i < len; ++i) {
|
for (var i = 0, len = specs.length; i < len; ++i) {
|
||||||
var filename = specs[i];
|
var filename = specs[i];
|
||||||
require(filename.replace(/\.\w+$/, ""));
|
require(filename.replace(/\.\w+$/, ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
var jasmineEnv = jasmine.getEnv();
|
var jasmineEnv = jasmine.getEnv();
|
||||||
var consoleReporter = new jasmine.TrivialConsoleReporter(sys.print, done);
|
var consoleReporter = new jasmine.TrivialConsoleReporter(sys.print, done, showColors);
|
||||||
|
|
||||||
jasmineEnv.addReporter(consoleReporter);
|
jasmineEnv.addReporter(consoleReporter);
|
||||||
jasmineEnv.execute();
|
jasmineEnv.execute();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
jasmine.TrivialConsoleReporter = function(print, doneCallback) {
|
jasmine.TrivialConsoleReporter = function(print, doneCallback, showColors) {
|
||||||
//inspired by mhevery's jasmine-node reporter
|
//inspired by mhevery's jasmine-node reporter
|
||||||
//https://github.com/mhevery/jasmine-node
|
//https://github.com/mhevery/jasmine-node
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ jasmine.TrivialConsoleReporter = function(print, doneCallback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function coloredStr(color, str) {
|
function coloredStr(color, str) {
|
||||||
return ansi[color] + str + ansi.none;
|
return showColors ? (ansi[color] + str + ansi.none) : str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function greenStr(str) {
|
function greenStr(str) {
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ jasmine.version_= {
|
|||||||
"major": 1,
|
"major": 1,
|
||||||
"minor": 1,
|
"minor": 1,
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"revision": 1308238364,
|
"revision": 1308288659,
|
||||||
"rc": 1
|
"rc": 1
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
desc "Build core jasmine.js"
|
desc "Build core jasmine.js"
|
||||||
task :build_dist => [:lint, :write_version_file] do
|
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.js') { core_sources + version_source_file }
|
||||||
concat_into('lib/jasmine-html.js') { html_sources }
|
concat_into('lib/jasmine-html.js') { html_sources }
|
||||||
@@ -19,7 +19,7 @@ end
|
|||||||
|
|
||||||
desc 'Check jasmine sources for coding problems'
|
desc 'Check jasmine sources for coding problems'
|
||||||
task :lint do
|
task :lint do
|
||||||
puts "Running JSHint via Node.js"
|
puts "Running JSHint via Node.js".cyan
|
||||||
system("node jshint/run.js") || exit(1)
|
system("node jshint/run.js") || exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,15 @@ task :spec => ["build_dist", "count_specs", "spec:node", "spec:browser"]
|
|||||||
|
|
||||||
desc 'Run specs in Node.js'
|
desc 'Run specs in Node.js'
|
||||||
task "spec:node" => [:count_specs, :require_node] do
|
task "spec:node" => [:count_specs, :require_node] do
|
||||||
puts "Running all appropriate specs via Node.js"
|
puts "Running all appropriate specs via Node.js".cyan
|
||||||
system("node spec/node_suite.js")
|
|
||||||
|
color = Term::ANSIColor.coloring? ? "--color" : "--noColor"
|
||||||
|
system("node spec/node_suite.js #{color}")
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Run specs in the default browser (MacOS only)"
|
desc "Run specs in the default browser (MacOS only)"
|
||||||
task "spec:browser" => [:count_specs, :build_runner_html] do
|
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")
|
system("open spec/runner.html")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -20,8 +22,8 @@ task :count_specs do
|
|||||||
html_spec_count = count_specs_in(Dir.glob('spec/html/*.js'))
|
html_spec_count = count_specs_in(Dir.glob('spec/html/*.js'))
|
||||||
|
|
||||||
puts "\n"
|
puts "\n"
|
||||||
puts "#{yellow(core_specs_count + console_spec_count)} specs for Node.js runner (exclude DOM-related specs)"
|
puts "#{(core_specs_count + console_spec_count).to_s.yellow.bold} 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 + html_spec_count).to_s.yellow.bold} specs for Browser runner (all specs)"
|
||||||
puts "\n"
|
puts "\n"
|
||||||
puts "Please verify that these numbers match the runner output."
|
puts "Please verify that these numbers match the runner output."
|
||||||
puts "\n"
|
puts "\n"
|
||||||
@@ -33,7 +35,3 @@ def count_specs_in(files)
|
|||||||
count
|
count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def yellow(str)
|
|
||||||
"\033[33m#{str}\033[0m"
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user