Isolated env will log output of command as it comes. Update tests.
This commit is contained in:
parent
bb4f7b6418
commit
55f2ac3f54
|
@ -9,7 +9,7 @@ class BoxTest < AcceptanceTest
|
||||||
|
|
||||||
should "have no boxes by default" do
|
should "have no boxes by default" do
|
||||||
result = execute("vagrant", "box", "list")
|
result = execute("vagrant", "box", "list")
|
||||||
assert result.stdout.read =~ /There are no installed boxes!/
|
assert result.stdout =~ /There are no installed boxes!/
|
||||||
end
|
end
|
||||||
|
|
||||||
should "add a box from a file" do
|
should "add a box from a file" do
|
||||||
|
@ -21,13 +21,13 @@ class BoxTest < AcceptanceTest
|
||||||
|
|
||||||
# Verify that the box now shows up in the list of available boxes
|
# Verify that the box now shows up in the list of available boxes
|
||||||
results = execute("vagrant", "box", "list")
|
results = execute("vagrant", "box", "list")
|
||||||
assert(results.stdout.read =~ /^foo$/, "Box should exist after it is added")
|
assert(results.stdout =~ /^foo$/, "Box should exist after it is added")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "give an error if the file doesn't exist" do
|
should "give an error if the file doesn't exist" do
|
||||||
results = execute("vagrant", "box", "add", "foo", "/tmp/nope/nope/nope/nonono.box")
|
results = execute("vagrant", "box", "add", "foo", "/tmp/nope/nope/nope/nonono.box")
|
||||||
assert(!results.success?, "Box add should fail.")
|
assert(!results.success?, "Box add should fail.")
|
||||||
assert(results.stdout.read =~ /^The specified path to a file doesn't exist.$/,
|
assert(results.stdout =~ /^The specified path to a file doesn't exist.$/,
|
||||||
"This should show an error message about the file not existing.")
|
"This should show an error message about the file not existing.")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class BoxTest < AcceptanceTest
|
||||||
|
|
||||||
results = execute("vagrant", "box", "add", "foo", invalid.to_s)
|
results = execute("vagrant", "box", "add", "foo", invalid.to_s)
|
||||||
assert(!results.success?, "Box add should fail.")
|
assert(!results.success?, "Box add should fail.")
|
||||||
assert(results.stdout.read =~ /^The box file you're attempting to add is invalid./,
|
assert(results.stdout =~ /^The box file you're attempting to add is invalid./,
|
||||||
"should show an error message")
|
"should show an error message")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class BoxTest < AcceptanceTest
|
||||||
execute("vagrant", "box", "remove", "foo")
|
execute("vagrant", "box", "remove", "foo")
|
||||||
results = execute("vagrant", "box", "list")
|
results = execute("vagrant", "box", "list")
|
||||||
assert(results.success?, "box list should succeed")
|
assert(results.success?, "box list should succeed")
|
||||||
assert(results.stdout.read =~ /^There are no installed boxes!/,
|
assert(results.stdout =~ /^There are no installed boxes!/,
|
||||||
"box list should be empty")
|
"box list should be empty")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -55,17 +55,37 @@ module Acceptance
|
||||||
|
|
||||||
# Execute in a separate process, wait for it to complete, and
|
# Execute in a separate process, wait for it to complete, and
|
||||||
# return the IO streams.
|
# return the IO streams.
|
||||||
@logger.info("Executing: #{command} #{argN.inspect}")
|
@logger.info("Executing: #{command} #{argN.inspect}. Output will stream in...")
|
||||||
pid, stdin, stdout, stderr = popen4(@env, command, *argN)
|
pid, stdin, stdout, stderr = popen4(@env, command, *argN)
|
||||||
_pid, status = Process.waitpid2(pid)
|
|
||||||
@logger.info("Exit status: #{status.exitstatus}")
|
|
||||||
|
|
||||||
return ExecuteProcess.new(status.exitstatus, stdout, stderr)
|
io_data = {
|
||||||
|
stdout => "",
|
||||||
|
stderr => ""
|
||||||
|
}
|
||||||
|
|
||||||
|
while results = IO.select([stdout, stderr], nil, nil, 5)
|
||||||
|
rs = results[0]
|
||||||
|
next if rs.empty?
|
||||||
|
|
||||||
|
rs.each do |r|
|
||||||
|
data = r.readline
|
||||||
|
io_data[r] += data
|
||||||
|
|
||||||
|
io_name = r == stdout ? "stdout" : "stderr"
|
||||||
|
@logger.debug("[#{io_name}] #{data.chomp}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
_pid, status = Process.waitpid2(pid)
|
||||||
|
@logger.debug("Exit status: #{status.exitstatus}")
|
||||||
|
|
||||||
|
return ExecuteProcess.new(status.exitstatus, io_data[stdout], io_data[stderr])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Closes the environment, cleans up the temporary directories, etc.
|
# Closes the environment, cleans up the temporary directories, etc.
|
||||||
def close
|
def close
|
||||||
# Delete the temporary directory
|
# Delete the temporary directory
|
||||||
|
@logger.info("Removing isolated environment: #{@tempdir.path}")
|
||||||
FileUtils.rm_rf(@tempdir.path)
|
FileUtils.rm_rf(@tempdir.path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ SCRIPT
|
||||||
end
|
end
|
||||||
|
|
||||||
result = execute("expect", "color.exp")
|
result = execute("expect", "color.exp")
|
||||||
assert(has_color?(result.stdout.read), "output should contain color")
|
assert(has_color?(result.stdout), "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
|
||||||
|
@ -41,7 +41,7 @@ SCRIPT
|
||||||
end
|
end
|
||||||
|
|
||||||
result = execute("expect", "color.exp")
|
result = execute("expect", "color.exp")
|
||||||
assert(!has_color?(result.stdout.read), "output should not contain color")
|
assert(!has_color?(result.stdout), "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
|
||||||
|
@ -50,6 +50,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(!has_color?(result.stdout.read), "output should not contain color")
|
assert(!has_color?(result.stdout), "output should not contain color")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,16 +3,19 @@ require File.expand_path("../base", __FILE__)
|
||||||
class VersionTest < AcceptanceTest
|
class VersionTest < AcceptanceTest
|
||||||
should "print the version to stdout" do
|
should "print the version to stdout" do
|
||||||
result = execute("vagrant", "version")
|
result = execute("vagrant", "version")
|
||||||
assert_equal("Vagrant version #{config.vagrant_version}\n", result.stdout.read)
|
assert(result.stdout =~ /^Vagrant version #{config.vagrant_version}$/,
|
||||||
|
"output should contain Vagrant version")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "print the version with '-v'" do
|
should "print the version with '-v'" do
|
||||||
result = execute("vagrant", "-v")
|
result = execute("vagrant", "-v")
|
||||||
assert_equal("Vagrant version #{config.vagrant_version}\n", result.stdout.read)
|
assert(result.stdout =~ /^Vagrant version #{config.vagrant_version}$/,
|
||||||
|
"output should contain Vagrant version")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "print the version with '--version'" do
|
should "print the version with '--version'" do
|
||||||
result = execute("vagrant", "--version")
|
result = execute("vagrant", "--version")
|
||||||
assert_equal("Vagrant version #{config.vagrant_version}\n", result.stdout.read)
|
assert(result.stdout =~ /^Vagrant version #{config.vagrant_version}$/,
|
||||||
|
"output should contain Vagrant version")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue