Fix color tests
This commit is contained in:
parent
974c180d8f
commit
f741d81582
|
@ -66,8 +66,6 @@ module Acceptance
|
||||||
FileUtils.rm_rf(@tempdir.path)
|
FileUtils.rm_rf(@tempdir.path)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
# This replaces a command with a replacement defined when this
|
# This replaces a command with a replacement defined when this
|
||||||
# isolated environment was initialized. If nothing was defined,
|
# isolated environment was initialized. If nothing was defined,
|
||||||
# then the command itself is returned.
|
# then the command itself is returned.
|
||||||
|
|
|
@ -13,34 +13,28 @@ class VagrantTestColorOutput < AcceptanceTest
|
||||||
skip("Test requires `expect`") if !has_expect?
|
skip("Test requires `expect`") if !has_expect?
|
||||||
|
|
||||||
@environment.workdir.join("color.exp").open("w+") do |f|
|
@environment.workdir.join("color.exp").open("w+") do |f|
|
||||||
f.write(<<-SCRIPT)
|
f.puts(<<-SCRIPT)
|
||||||
catch {spawn vagrant status} reason
|
spawn #{@environment.replace_command("vagrant")} status
|
||||||
expect {
|
expect default {}
|
||||||
"\e[31m" { exit }
|
|
||||||
default { exit 1 }
|
|
||||||
}
|
|
||||||
SCRIPT
|
SCRIPT
|
||||||
end
|
end
|
||||||
|
|
||||||
results = execute("expect", "color.exp")
|
result = execute("expect", "color.exp")
|
||||||
assert_equal(0, results.exit_status)
|
assert(result.stdout.read.index("\e[31m"), "output should contain color")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not output color if there is a TTY but --no-color is present" do
|
should "not output color if there is a TTY but --no-color is present" do
|
||||||
skip("Test requires `expect`") if !has_expect?
|
skip("Test requires `expect`") if !has_expect?
|
||||||
|
|
||||||
@environment.workdir.join("color.exp").open("w+") do |f|
|
@environment.workdir.join("color.exp").open("w+") do |f|
|
||||||
f.write(<<-SCRIPT)
|
f.puts(<<-SCRIPT)
|
||||||
catch {spawn vagrant status --no-color} reason
|
spawn #{@environment.replace_command("vagrant")} status --no-color
|
||||||
expect {
|
expect default {}
|
||||||
"\e[31m" { exit 1 }
|
|
||||||
default { exit }
|
|
||||||
}
|
|
||||||
SCRIPT
|
SCRIPT
|
||||||
end
|
end
|
||||||
|
|
||||||
results = execute("expect", "color.exp")
|
result = execute("expect", "color.exp")
|
||||||
assert_equal(0, results.exit_status)
|
assert(!result.stdout.read.index("\e[31m"), "output should not contain color")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not output color in the absense of a TTY" do
|
should "not output color in the absense of a TTY" do
|
||||||
|
@ -49,6 +43,6 @@ SCRIPT
|
||||||
# If `vagrant status` itself is broken, another acceptance test
|
# If `vagrant status` itself is broken, another acceptance test
|
||||||
# should catch that. We just assume it works here.
|
# should catch that. We just assume it works here.
|
||||||
result = execute("vagrant", "status")
|
result = execute("vagrant", "status")
|
||||||
assert(result.stdout.read !~ /\e\[31/, "output should not contain color")
|
assert(!result.stdout.read.index("\e[31m"), "output should not contain color")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue