be more colorful - close #41
This commit is contained in:
1 parent
775363ddbd
commit
65c1bac4f9
7 files changed
+173
-50
No files matched your search
@@ -769,6 +769,29 @@ EOF
|
||||
expect(lines(result.stdout)).to eq ["165"]
|
||||
end
|
||||
|
||||
context "colored output" do
|
||||
it "does not output in color with --color=off" do
|
||||
test_dir("simple")
|
||||
result = run_test(rscons_args: %w[--color=off])
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.stdout).to_not match(/\e\[/)
|
||||
end
|
||||
|
||||
it "displays output in color with --color=force" do
|
||||
test_dir("simple")
|
||||
|
||||
result = run_test(rscons_args: %w[--color=force])
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.stdout).to match(/\e\[/)
|
||||
|
||||
File.open("simple.c", "wb") do |fh|
|
||||
fh.write("foobar")
|
||||
end
|
||||
result = run_test(rscons_args: %w[--color=force])
|
||||
expect(result.stderr).to match(/\e\[/)
|
||||
end
|
||||
end
|
||||
|
||||
context "backward compatibility" do
|
||||
it "allows a builder to call Environment#run_builder in a non-threaded manner" do
|
||||
test_dir("simple")
|
||||
@@ -791,6 +814,21 @@ EOF
|
||||
]
|
||||
end
|
||||
|
||||
it "prints the failed build command for a non-threaded builder" do
|
||||
test_dir("simple")
|
||||
File.open("simple.c", "wb") do |fh|
|
||||
fh.write(<<EOF)
|
||||
void one()
|
||||
{
|
||||
}
|
||||
EOF
|
||||
end
|
||||
result = run_test(rsconsfile: "build_sources.rb")
|
||||
expect(result.status).to_not eq 0
|
||||
expect(result.stderr).to match /main/
|
||||
expect(result.stdout).to match /Failed command was: gcc/
|
||||
end
|
||||
|
||||
it "prints the failed build command for a threaded builder when called via Environment#run_builder without delayed execution" do
|
||||
test_dir("simple")
|
||||
File.open("simple.c", "wb") do |fh|
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
module Rscons
|
||||
describe Ansi do
|
||||
describe ".do_ansi?" do
|
||||
|
||||
context "on Windows" do
|
||||
it "returns true when IO is a fifo on an xterm" do
|
||||
stub_const("RUBY_PLATFORM", "mingw")
|
||||
expect(ENV).to receive(:[]).with("TERM").and_return("xterm")
|
||||
io = double
|
||||
expect(io).to receive(:stat).and_return(Struct.new(:ftype).new("fifo"))
|
||||
expect(Ansi.__send__(:do_ansi?, io)).to be_truthy
|
||||
end
|
||||
|
||||
it "returns false when TERM is not set appropriately" do
|
||||
stub_const("RUBY_PLATFORM", "mingw")
|
||||
expect(ENV).to receive(:[]).with("TERM").and_return(nil)
|
||||
io = double
|
||||
expect(Ansi.__send__(:do_ansi?, io)).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
context "on POSIX" do
|
||||
it "returns true when IO is a TTY" do
|
||||
stub_const("RUBY_PLATFORM", "linux")
|
||||
io = double
|
||||
expect(io).to receive(:tty?).and_return(true)
|
||||
expect(Ansi.__send__(:do_ansi?, io)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -190,38 +190,6 @@ module Rscons
|
||||
end
|
||||
end
|
||||
|
||||
describe "#execute" do
|
||||
context "with echo: :short" do
|
||||
context "with no errors" do
|
||||
it "prints the short description and executes the command" do
|
||||
env = Environment.new(echo: :short)
|
||||
expect(env).to receive(:puts).with("short desc")
|
||||
expect(env).to receive(:system).with(*Rscons.command_executer, "a", "command").and_return(true)
|
||||
env.execute("short desc", ["a", "command"])
|
||||
end
|
||||
end
|
||||
|
||||
context "with errors" do
|
||||
it "prints the short description, executes the command, and prints the failed command line" do
|
||||
env = Environment.new(echo: :short)
|
||||
expect(env).to receive(:puts).with("short desc")
|
||||
expect(env).to receive(:system).with(*Rscons.command_executer, "a", "command").and_return(false)
|
||||
expect($stdout).to receive(:puts).with("Failed command was: a command")
|
||||
env.execute("short desc", ["a", "command"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with echo: :command" do
|
||||
it "prints the command executed and executes the command" do
|
||||
env = Environment.new(echo: :command)
|
||||
expect(env).to receive(:puts).with("a command '--arg=val with spaces'")
|
||||
expect(env).to receive(:system).with({modified: :environment}, *Rscons.command_executer, "a", "command", "--arg=val with spaces", {opt: :val}).and_return(false)
|
||||
env.execute("short desc", ["a", "command", "--arg=val with spaces"], env: {modified: :environment}, options: {opt: :val})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#method_missing" do
|
||||
it "calls the original method missing when the target method is not a known builder" do
|
||||
env = Environment.new
|
||||
|
||||
Reference in new issue
Block a user