vagrantup 0.8.10 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +77 -1
- data/Gemfile +0 -14
- data/LICENSE +1 -1
- data/bin/vagrant +47 -20
- data/config/default.rb +6 -14
- data/lib/vagrant/action/box/destroy.rb +7 -3
- data/lib/vagrant/action/box/download.rb +8 -8
- data/lib/vagrant/action/box/package.rb +2 -2
- data/lib/vagrant/action/box/unpackage.rb +13 -7
- data/lib/vagrant/action/box/verify.rb +5 -5
- data/lib/vagrant/action/builder.rb +23 -19
- data/lib/vagrant/action/builtin.rb +117 -79
- data/lib/vagrant/action/env/set.rb +7 -4
- data/lib/vagrant/action/environment.rb +3 -41
- data/lib/vagrant/action/general/package.rb +14 -29
- data/lib/vagrant/action/general/validate.rb +2 -2
- data/lib/vagrant/action/runner.rb +53 -0
- data/lib/vagrant/action/vm/boot.rb +9 -9
- data/lib/vagrant/action/vm/check_accessible.rb +2 -2
- data/lib/vagrant/action/vm/check_box.rb +10 -12
- data/lib/vagrant/action/vm/check_guest_additions.rb +8 -8
- data/lib/vagrant/action/vm/check_port_collisions.rb +85 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +4 -4
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +3 -11
- data/lib/vagrant/action/vm/clear_network_interfaces.rb +31 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +2 -11
- data/lib/vagrant/action/vm/customize.rb +19 -9
- data/lib/vagrant/action/vm/destroy.rb +4 -4
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +2 -12
- data/lib/vagrant/action/vm/discard_state.rb +4 -4
- data/lib/vagrant/action/vm/export.rb +13 -8
- data/lib/vagrant/action/vm/forward_ports.rb +55 -102
- data/lib/vagrant/action/vm/halt.rb +9 -6
- data/lib/vagrant/action/vm/host_name.rb +4 -4
- data/lib/vagrant/action/vm/import.rb +19 -10
- data/lib/vagrant/action/vm/match_mac_address.rb +4 -9
- data/lib/vagrant/action/vm/network.rb +300 -94
- data/lib/vagrant/action/vm/nfs.rb +41 -26
- data/lib/vagrant/action/vm/package.rb +1 -1
- data/lib/vagrant/action/vm/package_vagrantfile.rb +5 -2
- data/lib/vagrant/action/vm/provision.rb +42 -13
- data/lib/vagrant/action/vm/provisioner_cleanup.rb +2 -2
- data/lib/vagrant/action/vm/{clear_nfs_exports.rb → prune_nfs_exports.rb} +7 -7
- data/lib/vagrant/action/vm/resume.rb +4 -4
- data/lib/vagrant/action/vm/setup_package_files.rb +54 -0
- data/lib/vagrant/action/vm/share_folders.rb +63 -39
- data/lib/vagrant/action/vm/suspend.rb +4 -4
- data/lib/vagrant/action/warden.rb +13 -6
- data/lib/vagrant/action.rb +45 -123
- data/lib/vagrant/box.rb +9 -55
- data/lib/vagrant/box_collection.rb +22 -17
- data/lib/vagrant/cli.rb +62 -47
- data/lib/vagrant/command/base.rb +135 -90
- data/lib/vagrant/command/box.rb +46 -21
- data/lib/vagrant/command/box_add.rb +33 -0
- data/lib/vagrant/command/box_list.rb +25 -0
- data/lib/vagrant/command/box_remove.rb +23 -0
- data/lib/vagrant/command/box_repackage.rb +23 -0
- data/lib/vagrant/command/destroy.rb +16 -5
- data/lib/vagrant/command/halt.rb +25 -7
- data/lib/vagrant/command/init.rb +30 -7
- data/lib/vagrant/command/package.rb +49 -18
- data/lib/vagrant/command/provision.rb +22 -9
- data/lib/vagrant/command/reload.rb +18 -5
- data/lib/vagrant/command/resume.rb +18 -5
- data/lib/vagrant/command/ssh.rb +69 -31
- data/lib/vagrant/command/ssh_config.rb +37 -22
- data/lib/vagrant/command/status.rb +22 -20
- data/lib/vagrant/command/suspend.rb +18 -5
- data/lib/vagrant/command/up.rb +41 -8
- data/lib/vagrant/command.rb +18 -20
- data/lib/vagrant/communication/base.rb +56 -0
- data/lib/vagrant/communication/ssh.rb +200 -0
- data/lib/vagrant/communication.rb +7 -0
- data/lib/vagrant/config/base.rb +18 -26
- data/lib/vagrant/config/container.rb +37 -0
- data/lib/vagrant/config/error_recorder.rb +1 -1
- data/lib/vagrant/config/loader.rb +125 -0
- data/lib/vagrant/config/nfs.rb +1 -3
- data/lib/vagrant/config/package.rb +1 -3
- data/lib/vagrant/config/ssh.rb +31 -16
- data/lib/vagrant/config/top.rb +36 -25
- data/lib/vagrant/config/vagrant.rb +2 -5
- data/lib/vagrant/config/vm/provisioner.rb +16 -20
- data/lib/vagrant/config/vm/sub_vm.rb +1 -1
- data/lib/vagrant/config/vm.rb +115 -56
- data/lib/vagrant/config.rb +29 -103
- data/lib/vagrant/data_store.rb +23 -15
- data/lib/vagrant/downloaders/base.rb +7 -5
- data/lib/vagrant/downloaders/file.rb +4 -4
- data/lib/vagrant/downloaders/http.rb +4 -5
- data/lib/vagrant/driver/virtualbox.rb +121 -0
- data/lib/vagrant/driver/virtualbox_4_0.rb +411 -0
- data/lib/vagrant/driver/virtualbox_4_1.rb +411 -0
- data/lib/vagrant/driver/virtualbox_base.rb +284 -0
- data/lib/vagrant/driver.rb +7 -0
- data/lib/vagrant/environment.rb +221 -240
- data/lib/vagrant/errors.rb +74 -25
- data/lib/vagrant/guest/arch.rb +48 -0
- data/lib/vagrant/{systems → guest}/base.rb +30 -18
- data/lib/vagrant/guest/debian.rb +61 -0
- data/lib/vagrant/{systems → guest}/freebsd.rb +11 -18
- data/lib/vagrant/guest/gentoo.rb +32 -0
- data/lib/vagrant/{systems → guest}/linux/config.rb +2 -4
- data/lib/vagrant/guest/linux/error.rb +9 -0
- data/lib/vagrant/guest/linux.rb +78 -0
- data/lib/vagrant/guest/redhat.rb +66 -0
- data/lib/vagrant/guest/solaris.rb +114 -0
- data/lib/vagrant/{systems → guest}/suse.rb +2 -2
- data/lib/vagrant/guest/ubuntu.rb +23 -0
- data/lib/vagrant/guest.rb +16 -0
- data/lib/vagrant/hosts/arch.rb +7 -3
- data/lib/vagrant/hosts/base.rb +36 -46
- data/lib/vagrant/hosts/bsd.rb +53 -16
- data/lib/vagrant/hosts/fedora.rb +14 -0
- data/lib/vagrant/hosts/freebsd.rb +6 -36
- data/lib/vagrant/hosts/linux.rb +45 -20
- data/lib/vagrant/hosts/windows.rb +16 -0
- data/lib/vagrant/hosts.rb +23 -6
- data/lib/vagrant/provisioners/base.rb +11 -34
- data/lib/vagrant/provisioners/chef.rb +30 -26
- data/lib/vagrant/provisioners/chef_client.rb +37 -23
- data/lib/vagrant/provisioners/chef_solo.rb +61 -16
- data/lib/vagrant/provisioners/puppet.rb +70 -38
- data/lib/vagrant/provisioners/puppet_server.rb +12 -13
- data/lib/vagrant/provisioners/shell.rb +24 -24
- data/lib/vagrant/provisioners.rb +10 -7
- data/lib/vagrant/registry.rb +49 -0
- data/lib/vagrant/ssh.rb +82 -153
- data/lib/vagrant/ui.rb +118 -50
- data/lib/vagrant/util/busy.rb +1 -1
- data/lib/vagrant/util/file_mode.rb +12 -0
- data/lib/vagrant/util/network_ip.rb +28 -0
- data/lib/vagrant/util/platform.rb +1 -0
- data/lib/vagrant/util/subprocess.rb +227 -0
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +111 -97
- data/lib/vagrant.rb +132 -5
- data/tasks/acceptance.rake +3 -3
- data/tasks/test.rake +7 -2
- data/templates/commands/init/Vagrantfile.erb +11 -4
- data/templates/{ssh_config.erb → commands/ssh_config/config.erb} +0 -0
- data/templates/guests/arch/network_dhcp.erb +7 -0
- data/templates/guests/arch/network_static.erb +7 -0
- data/templates/guests/debian/network_dhcp.erb +6 -0
- data/templates/guests/debian/network_static.erb +7 -0
- data/templates/guests/gentoo/network_dhcp.erb +4 -0
- data/templates/guests/gentoo/network_static.erb +4 -0
- data/templates/guests/redhat/network_dhcp.erb +6 -0
- data/templates/guests/redhat/network_static.erb +7 -0
- data/templates/locales/en.yml +241 -122
- data/templates/{chef_server_client.erb → provisioners/chef_client/client.erb} +0 -0
- data/templates/{chef_solo_solo.erb → provisioners/chef_solo/solo.erb} +0 -0
- data/test/acceptance/base.rb +10 -10
- data/test/acceptance/box_test.rb +28 -6
- data/test/acceptance/destroy_test.rb +1 -1
- data/test/acceptance/halt_test.rb +4 -4
- data/test/acceptance/init_test.rb +3 -3
- data/test/acceptance/networking/host_only_test.rb +37 -0
- data/test/acceptance/networking/port_forward_test.rb +125 -0
- data/test/acceptance/package_test.rb +46 -0
- data/test/acceptance/provisioning/basic_test.rb +61 -0
- data/test/acceptance/provisioning/chef_solo_test.rb +37 -0
- data/test/acceptance/provisioning/shell_test.rb +53 -0
- data/test/acceptance/resume_test.rb +1 -1
- data/test/acceptance/skeletons/chef_solo_basic/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_basic/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/skeletons/chef_solo_json/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_json/cookbooks/basic/recipes/default.rb +6 -0
- data/test/acceptance/skeletons/provisioner_multi/README.md +3 -0
- data/test/acceptance/skeletons/provisioner_multi/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/ssh_test.rb +7 -2
- data/test/acceptance/support/config.rb +1 -1
- data/test/acceptance/support/isolated_environment.rb +41 -150
- data/test/acceptance/support/matchers/match_output.rb +1 -1
- data/test/acceptance/support/matchers/succeed.rb +14 -0
- data/test/acceptance/support/network_tests.rb +29 -0
- data/test/acceptance/support/output.rb +9 -1
- data/test/acceptance/support/shared/base_context.rb +16 -9
- data/test/acceptance/support/shared/command_examples.rb +4 -4
- data/test/acceptance/suspend_test.rb +1 -1
- data/test/acceptance/up_basic_test.rb +26 -7
- data/test/acceptance/up_with_box_url.rb +1 -1
- data/test/acceptance/vagrant_test.rb +1 -1
- data/test/acceptance/version_test.rb +0 -5
- data/test/support/isolated_environment.rb +46 -0
- data/test/{acceptance/support → support}/tempdir.rb +0 -0
- data/test/unit/base.rb +21 -0
- data/test/unit/support/isolated_environment.rb +39 -0
- data/test/unit/support/shared/base_context.rb +30 -0
- data/test/unit/vagrant/action/builder_test.rb +126 -177
- data/test/unit/vagrant/action/environment_test.rb +10 -21
- data/test/unit/vagrant/action/runner_test.rb +65 -0
- data/test/unit/vagrant/action/warden_test.rb +64 -97
- data/test/unit/vagrant/box_collection_test.rb +44 -33
- data/test/unit/vagrant/box_test.rb +25 -65
- data/test/unit/vagrant/command/base_test.rb +141 -14
- data/test/unit/vagrant/config/base_test.rb +16 -43
- data/test/unit/vagrant/config/loader_test.rb +79 -0
- data/test/unit/vagrant/config/top_test.rb +69 -0
- data/test/unit/vagrant/config/vm_test.rb +62 -47
- data/test/unit/vagrant/config_test.rb +16 -151
- data/test/unit/vagrant/data_store_test.rb +43 -61
- data/test/unit/vagrant/downloaders/base_test.rb +12 -22
- data/test/unit/vagrant/downloaders/file_test.rb +58 -31
- data/test/unit/vagrant/downloaders/http_test.rb +12 -86
- data/test/unit/vagrant/environment_test.rb +107 -536
- data/test/unit/vagrant/hosts_test.rb +36 -0
- data/test/unit/vagrant/registry_test.rb +56 -0
- data/test/unit/vagrant/util/file_checksum_test.rb +23 -0
- data/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +23 -24
- data/test/unit/vagrant/util/network_ip_test.rb +17 -0
- data/test/unit/vagrant/util/retryable_test.rb +90 -34
- data/test/unit/vagrant_test.rb +27 -0
- data/test/{unit → unit_legacy}/locales/en.yml +0 -0
- data/test/{unit → unit_legacy}/test_helper.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/destroy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/download_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/unpackage_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/verify_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/env/set_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/general/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/general/validate_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/boot_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_accessible_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_box_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_guest_additions_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clean_machine_folder_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_forwarded_ports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_nfs_exports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_shared_folders_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/customize_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/discard_state_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/export_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/halt_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/host_name_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/import_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/match_mac_address_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/modify_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/network_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/package_vagrantfile_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/provision_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/provisioner_cleanup_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/resume_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/share_folders_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/suspend_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action_test.rb +0 -0
- data/test/unit_legacy/vagrant/box_collection_test.rb +45 -0
- data/test/unit_legacy/vagrant/box_test.rb +74 -0
- data/test/{unit → unit_legacy}/vagrant/cli_test.rb +0 -0
- data/test/unit_legacy/vagrant/command/base_test.rb +23 -0
- data/test/{unit → unit_legacy}/vagrant/command/group_base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/init_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/package_test.rb +0 -0
- data/test/unit_legacy/vagrant/config/base_test.rb +52 -0
- data/test/{unit → unit_legacy}/vagrant/config/error_recorder_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/ssh_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/vagrant_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/vm/provisioner_test.rb +0 -0
- data/test/unit_legacy/vagrant/config/vm_test.rb +47 -0
- data/test/unit_legacy/vagrant/config_test.rb +148 -0
- data/test/unit_legacy/vagrant/downloaders/http_test.rb +93 -0
- data/test/unit_legacy/vagrant/environment_test.rb +539 -0
- data/test/{unit → unit_legacy}/vagrant/errors_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/bsd_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/linux_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/plugin_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_client_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_solo_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_server_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/shell_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/ssh/session_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/ssh_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/systems/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/systems/linux_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/busy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/counter_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/platform_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/stacked_proc_runner_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/template_renderer_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/vm_test.rb +0 -0
- data/vagrant.gemspec +7 -9
- metadata +183 -179
- data/keys/vagrant.ppk +0 -26
- data/lib/vagrant/action/box.rb +0 -11
- data/lib/vagrant/action/env.rb +0 -7
- data/lib/vagrant/action/general.rb +0 -8
- data/lib/vagrant/action/vm/forward_ports_helpers.rb +0 -28
- data/lib/vagrant/action/vm/modify.rb +0 -37
- data/lib/vagrant/action/vm/nfs_helpers.rb +0 -11
- data/lib/vagrant/action/vm.rb +0 -34
- data/lib/vagrant/command/group_base.rb +0 -107
- data/lib/vagrant/command/helpers.rb +0 -33
- data/lib/vagrant/command/named_base.rb +0 -14
- data/lib/vagrant/command/upgrade_to_060.rb +0 -45
- data/lib/vagrant/command/version.rb +0 -13
- data/lib/vagrant/ssh/session.rb +0 -136
- data/lib/vagrant/systems/arch.rb +0 -34
- data/lib/vagrant/systems/debian.rb +0 -36
- data/lib/vagrant/systems/gentoo.rb +0 -27
- data/lib/vagrant/systems/linux/error.rb +0 -9
- data/lib/vagrant/systems/linux.rb +0 -82
- data/lib/vagrant/systems/redhat.rb +0 -48
- data/lib/vagrant/systems/solaris.rb +0 -113
- data/lib/vagrant/systems/ubuntu.rb +0 -17
- data/lib/vagrant/systems.rb +0 -13
- data/templates/network_entry_arch.erb +0 -9
- data/templates/network_entry_debian.erb +0 -8
- data/templates/network_entry_gentoo.erb +0 -5
- data/templates/network_entry_redhat.erb +0 -9
- data/test/unit/vagrant/ui_test.rb +0 -29
@@ -4,142 +4,65 @@ require "pathname"
|
|
4
4
|
require "log4r"
|
5
5
|
require "childprocess"
|
6
6
|
|
7
|
-
require
|
8
|
-
|
7
|
+
require "vagrant/util/subprocess"
|
8
|
+
|
9
|
+
require "acceptance/support/virtualbox"
|
10
|
+
require "support/isolated_environment"
|
9
11
|
|
10
12
|
module Acceptance
|
11
13
|
# This class manages an isolated environment for Vagrant to
|
12
14
|
# run in. It creates a temporary directory to act as the
|
13
15
|
# working directory as well as sets a custom home directory.
|
14
|
-
class IsolatedEnvironment
|
15
|
-
|
16
|
-
attr_reader :workdir
|
16
|
+
class IsolatedEnvironment < ::IsolatedEnvironment
|
17
|
+
SKELETON_DIR = Pathname.new(File.expand_path("../../skeletons", __FILE__))
|
17
18
|
|
18
|
-
# Initializes an isolated environment. You can pass in some
|
19
|
-
# options here to configure runing custom applications in place
|
20
|
-
# of others as well as specifying environmental variables.
|
21
|
-
#
|
22
|
-
# @param [Hash] apps A mapping of application name (such as "vagrant")
|
23
|
-
# to an alternate full path to the binary to run.
|
24
|
-
# @param [Hash] env Additional environmental variables to inject
|
25
|
-
# into the execution environments.
|
26
19
|
def initialize(apps=nil, env=nil)
|
27
|
-
|
28
|
-
|
29
|
-
@apps = apps || {}
|
30
|
-
@env = env || {}
|
31
|
-
|
32
|
-
# Create a temporary directory for our work
|
33
|
-
@tempdir = Tempdir.new("vagrant")
|
34
|
-
@logger.info("Initialize isolated environment: #{@tempdir.path}")
|
20
|
+
super()
|
35
21
|
|
36
|
-
|
37
|
-
@homedir = Pathname.new(File.join(@tempdir.path, "home"))
|
38
|
-
@workdir = Pathname.new(File.join(@tempdir.path, "work"))
|
22
|
+
@logger = Log4r::Logger.new("test::acceptance::isolated_environment")
|
39
23
|
|
40
|
-
@
|
41
|
-
@
|
24
|
+
@apps = apps.clone || {}
|
25
|
+
@env = env.clone || {}
|
42
26
|
|
43
27
|
# Set the home directory and virtualbox home directory environmental
|
44
28
|
# variables so that Vagrant and VirtualBox see the proper paths here.
|
45
|
-
@env["HOME"]
|
46
|
-
@env["VBOX_USER_HOME"]
|
29
|
+
@env["HOME"] ||= @homedir.to_s
|
30
|
+
@env["VBOX_USER_HOME"] ||= @homedir.to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
# Copies a skeleton into this isolated environment. This is useful
|
34
|
+
# for testing environments that require a complex setup.
|
35
|
+
#
|
36
|
+
# @param [String] name Name of the skeleton in the skeletons/ directory.
|
37
|
+
def skeleton!(name)
|
38
|
+
# Copy all the files into the home directory
|
39
|
+
source = Dir.glob(SKELETON_DIR.join(name).join("*").to_s)
|
40
|
+
FileUtils.cp_r(source, @workdir.to_s)
|
47
41
|
end
|
48
42
|
|
49
43
|
# Executes a command in the context of this isolated environment.
|
50
44
|
# Any command executed will therefore see our temporary directory
|
51
45
|
# as the home directory.
|
52
46
|
def execute(command, *argN)
|
47
|
+
# Create the command
|
53
48
|
command = replace_command(command)
|
54
49
|
|
55
|
-
#
|
50
|
+
# Determine the options
|
56
51
|
options = argN.last.is_a?(Hash) ? argN.pop : {}
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
@env.each do |k, v|
|
72
|
-
process.environment[k] = v
|
73
|
-
end
|
74
|
-
|
75
|
-
Dir.chdir(@workdir.to_s) do
|
76
|
-
process.start
|
77
|
-
process.io.stdin.sync = true
|
78
|
-
end
|
79
|
-
|
80
|
-
# Close our side of the pipes, since we're just reading
|
81
|
-
stdout_writer.close
|
82
|
-
stderr_writer.close
|
83
|
-
|
84
|
-
# Create a hash to store all the data we see.
|
85
|
-
io_data = { stdout => "", stderr => "" }
|
86
|
-
|
87
|
-
# Record the start time for timeout purposes
|
88
|
-
start_time = Time.now.to_i
|
89
|
-
|
90
|
-
@logger.debug("Selecting on IO...")
|
91
|
-
while true
|
92
|
-
results = IO.select([stdout, stderr],
|
93
|
-
[process.io.stdin], nil, timeout || 5)
|
94
|
-
|
95
|
-
# Check if we have exceeded our timeout from waiting on a select()
|
96
|
-
raise TimeoutExceeded, process.pid if timeout && (Time.now.to_i - start_time) > timeout
|
97
|
-
|
98
|
-
# Check the readers first to see if they're ready
|
99
|
-
readers = results[0]
|
100
|
-
if !readers.empty?
|
101
|
-
begin
|
102
|
-
readers.each do |r|
|
103
|
-
data = r.read_nonblock(1024)
|
104
|
-
io_data[r] += data
|
105
|
-
io_name = r == stdout ? "stdout" : "stderr"
|
106
|
-
@logger.debug(data)
|
107
|
-
yield io_name.to_sym, data if block_given?
|
108
|
-
end
|
109
|
-
rescue IO::WaitReadable
|
110
|
-
# This just means the IO wasn't actually ready and we should
|
111
|
-
# wait some more. So we just let this pass through.
|
112
|
-
rescue EOFError
|
113
|
-
# Process exited, so break out of this while loop
|
114
|
-
break
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
# Check if the process exited in order to break the loop before
|
119
|
-
# we try to see if any stdin is ready.
|
120
|
-
break if process.exited?
|
121
|
-
|
122
|
-
# Check the writers to see if they're ready, and notify any listeners
|
123
|
-
if !results[1].empty?
|
124
|
-
yield :stdin, process.io.stdin if block_given?
|
125
|
-
end
|
52
|
+
options = {
|
53
|
+
:workdir => @workdir,
|
54
|
+
:env => @env
|
55
|
+
}.merge(options)
|
56
|
+
|
57
|
+
# Add the options to be passed on
|
58
|
+
argN << options
|
59
|
+
|
60
|
+
# Execute, logging out the stdout/stderr as we get it
|
61
|
+
@logger.info("Executing: #{[command].concat(argN).inspect}")
|
62
|
+
Vagrant::Util::Subprocess.execute(command, *argN) do |type, data|
|
63
|
+
@logger.debug("#{type}: #{data}") if type == :stdout || type == :stderr
|
64
|
+
yield type, data if block_given?
|
126
65
|
end
|
127
|
-
|
128
|
-
# Continually try to wait for the process to end, but do so asynchronously
|
129
|
-
# so that we can also check to see if we have exceeded a timeout.
|
130
|
-
begin
|
131
|
-
# If a timeout is not set, we set a very large timeout to
|
132
|
-
# simulate "forever"
|
133
|
-
@logger.debug("Waiting for process to exit...")
|
134
|
-
remaining = (timeout || 32000) - (Time.now.to_i - start_time)
|
135
|
-
remaining = 0 if remaining < 0
|
136
|
-
process.poll_for_exit(remaining)
|
137
|
-
rescue ChildProcess::TimeoutError
|
138
|
-
raise TimeoutExceeded, process.pid
|
139
|
-
end
|
140
|
-
|
141
|
-
@logger.debug("Exit status: #{process.exit_code}")
|
142
|
-
return ExecuteProcess.new(process.exit_code, io_data[stdout], io_data[stderr])
|
143
66
|
end
|
144
67
|
|
145
68
|
# Closes the environment, cleans up the temporary directories, etc.
|
@@ -149,9 +72,8 @@ module Acceptance
|
|
149
72
|
# environment.
|
150
73
|
delete_virtual_machines if VirtualBox.find_vboxsvc
|
151
74
|
|
152
|
-
#
|
153
|
-
|
154
|
-
FileUtils.rm_rf(@tempdir.path)
|
75
|
+
# Let the parent handle cleaning up
|
76
|
+
super
|
155
77
|
end
|
156
78
|
|
157
79
|
def delete_virtual_machines
|
@@ -167,7 +89,7 @@ module Acceptance
|
|
167
89
|
# reason it will simply freeze, although the VM is successfully
|
168
90
|
# "aborted." The timeout gets around this strange behavior.
|
169
91
|
execute("VBoxManage", "controlvm", data[:uuid], "poweroff", :timeout => 5)
|
170
|
-
rescue TimeoutExceeded => e
|
92
|
+
rescue Vagrant::Util::Subprocess::TimeoutExceeded => e
|
171
93
|
@logger.info("Failed to poweroff VM '#{data[:uuid]}'. Killing process.")
|
172
94
|
|
173
95
|
# Kill the process and wait a bit for it to disappear
|
@@ -178,7 +100,7 @@ module Acceptance
|
|
178
100
|
sleep 0.5
|
179
101
|
|
180
102
|
result = execute("VBoxManage", "unregistervm", data[:uuid], "--delete")
|
181
|
-
raise Exception, "VM unregistration failed!" if result.
|
103
|
+
raise Exception, "VM unregistration failed!" if result.exit_code != 0
|
182
104
|
end
|
183
105
|
|
184
106
|
@logger.info("Removed all virtual machines")
|
@@ -192,35 +114,4 @@ module Acceptance
|
|
192
114
|
return command
|
193
115
|
end
|
194
116
|
end
|
195
|
-
|
196
|
-
# This class represents a process which has run via the IsolatedEnvironment.
|
197
|
-
# This is a readonly structure that can be used to inspect the exit status,
|
198
|
-
# stdout, stderr, etc. from the process which ran.
|
199
|
-
class ExecuteProcess
|
200
|
-
attr_reader :exit_status
|
201
|
-
attr_reader :stdout
|
202
|
-
attr_reader :stderr
|
203
|
-
|
204
|
-
def initialize(exit_status, stdout, stderr)
|
205
|
-
@exit_status = exit_status
|
206
|
-
@stdout = stdout
|
207
|
-
@stderr = stderr
|
208
|
-
end
|
209
|
-
|
210
|
-
def success?
|
211
|
-
@exit_status == 0
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
# This exception is raised if the timeout for a process is exceeded.
|
216
|
-
class TimeoutExceeded < StandardError
|
217
|
-
attr_reader :pid
|
218
|
-
|
219
|
-
def initialize(pid)
|
220
|
-
@pid = pid
|
221
|
-
|
222
|
-
super()
|
223
|
-
end
|
224
|
-
end
|
225
117
|
end
|
226
|
-
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Matcher that verifies that a process succeeds.
|
2
|
+
RSpec::Matchers.define :succeed do
|
3
|
+
match do |thing|
|
4
|
+
thing.exit_code.should == 0
|
5
|
+
end
|
6
|
+
|
7
|
+
failure_message_for_should do |actual|
|
8
|
+
"expected process to succeed. exit code: #{actual.exit_code}"
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message_for_should_not do |actual|
|
12
|
+
"expected process to fail. exit code: #{actual.exit_code}"
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "vagrant/util/retryable"
|
2
|
+
|
3
|
+
module Acceptance
|
4
|
+
module NetworkTests
|
5
|
+
include Vagrant::Util::Retryable
|
6
|
+
|
7
|
+
# Tests that the host can access the VM through the network.
|
8
|
+
#
|
9
|
+
# @param [String] url URL to request from the host.
|
10
|
+
# @param [Integer] guest_port Port to run a web server on the guest.
|
11
|
+
def assert_host_to_vm_network(url, guest_port)
|
12
|
+
# Start up a web server in another thread by SSHing into the VM.
|
13
|
+
thr = Thread.new do
|
14
|
+
assert_execute("vagrant", "ssh", "-c", "python -m SimpleHTTPServer #{guest_port}")
|
15
|
+
end
|
16
|
+
|
17
|
+
# Verify that port forwarding works by making a simple HTTP request
|
18
|
+
# to the port. We should get a 200 response. We retry this a few times
|
19
|
+
# as we wait for the HTTP server to come online.
|
20
|
+
retryable(:tries => 5, :sleep => 2) do
|
21
|
+
result = Net::HTTP.get_response(URI.parse(url))
|
22
|
+
result.code.should == "200"
|
23
|
+
end
|
24
|
+
ensure
|
25
|
+
# The server needs to die. This is how.
|
26
|
+
thr.kill if thr
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -8,6 +8,10 @@ module Acceptance
|
|
8
8
|
@text = text
|
9
9
|
end
|
10
10
|
|
11
|
+
def box_already_exists(name)
|
12
|
+
@text =~ /^A box already exists under the name of '#{name}'/
|
13
|
+
end
|
14
|
+
|
11
15
|
# Checks that an error message was outputted about the box
|
12
16
|
# being added being invalid.
|
13
17
|
def box_invalid
|
@@ -33,7 +37,7 @@ module Acceptance
|
|
33
37
|
# Tests that the output says there is no Vagrantfile, and as such
|
34
38
|
# can't do whatever we requested Vagrant to do.
|
35
39
|
def no_vagrantfile
|
36
|
-
@text =~ /^
|
40
|
+
@text =~ /^A Vagrant environment is required/
|
37
41
|
end
|
38
42
|
|
39
43
|
# Tests that the output contains a specific Vagrant version.
|
@@ -41,6 +45,10 @@ module Acceptance
|
|
41
45
|
@text =~ /^Vagrant version #{version}$/
|
42
46
|
end
|
43
47
|
|
48
|
+
def resume_port_collision
|
49
|
+
@text =~ /^This VM cannot be resumed, because the forwarded ports/
|
50
|
+
end
|
51
|
+
|
44
52
|
# This checks that the VM with the given `vm_name` has the
|
45
53
|
# status of `status`.
|
46
54
|
def status(vm_name, status)
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require "support/isolated_environment"
|
2
|
-
require "support/output"
|
3
|
-
require "support/virtualbox"
|
1
|
+
require "acceptance/support/isolated_environment"
|
2
|
+
require "acceptance/support/output"
|
3
|
+
require "acceptance/support/virtualbox"
|
4
4
|
|
5
5
|
shared_context "acceptance" do
|
6
6
|
# Setup variables for the loggers of this test. These can be used to
|
7
7
|
# create more verbose logs for tests which can be useful in the case
|
8
8
|
# that a test fails.
|
9
9
|
let(:logger_name) { "logger" }
|
10
|
-
let(:logger) { Log4r::Logger.new("acceptance::#{logger_name}") }
|
10
|
+
let(:logger) { Log4r::Logger.new("test::acceptance::#{logger_name}") }
|
11
11
|
|
12
12
|
# This is the global configuration given by the acceptance test
|
13
13
|
# configurations.
|
@@ -18,10 +18,7 @@ shared_context "acceptance" do
|
|
18
18
|
# to replace "vagrant" with the proper path to Vagrant as well
|
19
19
|
# as tell the isolated environment about custom environmental
|
20
20
|
# variables to pass in.
|
21
|
-
let!(:environment)
|
22
|
-
apps = { "vagrant" => config.vagrant_path }
|
23
|
-
Acceptance::IsolatedEnvironment.new(apps, config.env)
|
24
|
-
end
|
21
|
+
let!(:environment) { new_environment }
|
25
22
|
|
26
23
|
before(:each) do
|
27
24
|
# Wait for VBoxSVC to disappear, since each test requires its
|
@@ -33,6 +30,16 @@ shared_context "acceptance" do
|
|
33
30
|
environment.close
|
34
31
|
end
|
35
32
|
|
33
|
+
# Creates a new isolated environment instance each time it is called.
|
34
|
+
#
|
35
|
+
# @return [Acceptance::IsolatedEnvironment]
|
36
|
+
def new_environment(env=nil)
|
37
|
+
apps = { "vagrant" => config.vagrant_path }
|
38
|
+
env = config.env.merge(env || {})
|
39
|
+
|
40
|
+
Acceptance::IsolatedEnvironment.new(apps, env)
|
41
|
+
end
|
42
|
+
|
36
43
|
# Executes the given command in the context of the isolated environment.
|
37
44
|
#
|
38
45
|
# @return [Object]
|
@@ -45,7 +52,7 @@ shared_context "acceptance" do
|
|
45
52
|
# exit status was successful.
|
46
53
|
def assert_execute(*args, &block)
|
47
54
|
result = execute(*args, &block)
|
48
|
-
assert(result.
|
55
|
+
assert(result.exit_code == 0, "expected '#{args.join(" ")}' to succeed")
|
49
56
|
result
|
50
57
|
end
|
51
58
|
|
@@ -9,8 +9,8 @@ shared_examples "a command that requires a Vagrantfile" do |*args|
|
|
9
9
|
|
10
10
|
it "fails if no Vagrantfile is found" do
|
11
11
|
result = execute(*command)
|
12
|
-
result.should_not
|
13
|
-
result.
|
12
|
+
result.should_not succeed
|
13
|
+
result.stderr.should match_output(:no_vagrantfile)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -27,7 +27,7 @@ shared_examples "a command that requires a virtual machine" do |*args|
|
|
27
27
|
assert_execute("vagrant", "init")
|
28
28
|
|
29
29
|
result = execute(*command)
|
30
|
-
result.should_not
|
31
|
-
result.
|
30
|
+
result.should_not succeed
|
31
|
+
result.stderr.should match_output(:error_vm_must_be_created)
|
32
32
|
end
|
33
33
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.expand_path("../base", __FILE__)
|
2
|
-
require "support/shared/command_examples"
|
2
|
+
require "acceptance/support/shared/command_examples"
|
3
3
|
|
4
4
|
describe "vagrant up", "basics" do
|
5
5
|
include_context "acceptance"
|
@@ -46,13 +46,32 @@ describe "vagrant up", "basics" do
|
|
46
46
|
foofile.exist?.should be, "'foo' should exist since it was touched in the shared folder"
|
47
47
|
end
|
48
48
|
|
49
|
-
|
49
|
+
it "should create a shared folder if the :create flag is set" do
|
50
|
+
initialize_valid_environment
|
51
|
+
|
52
|
+
# Setup the custom Vagrantfile
|
53
|
+
environment.workdir.join("Vagrantfile").open("w+") do |f|
|
54
|
+
f.write(<<-VF)
|
55
|
+
Vagrant::Config.run do |config|
|
56
|
+
config.vm.box = "base"
|
57
|
+
config.vm.share_folder "v-root", "/vagrant", "./data", :create => true
|
58
|
+
end
|
59
|
+
VF
|
60
|
+
end
|
61
|
+
|
62
|
+
data_dir = environment.workdir.join("data")
|
50
63
|
|
51
|
-
|
64
|
+
# Verify the directory doesn't exist prior, for sanity
|
65
|
+
data_dir.exist?.should_not be
|
52
66
|
|
53
|
-
|
54
|
-
|
55
|
-
|
67
|
+
# Bring up the VM
|
68
|
+
assert_execute("vagrant", "up")
|
69
|
+
|
70
|
+
# Verify the directory exists
|
71
|
+
data_dir.should be_directory
|
56
72
|
|
57
|
-
|
73
|
+
# Touch a file and verify it is shared
|
74
|
+
assert_execute("vagrant", "ssh", "-c", "touch /vagrant/foo")
|
75
|
+
data_dir.join("foo").exist?.should be
|
76
|
+
end
|
58
77
|
end
|
@@ -3,11 +3,6 @@ require File.expand_path("../base", __FILE__)
|
|
3
3
|
describe "vagrant version" do
|
4
4
|
include_context "acceptance"
|
5
5
|
|
6
|
-
it "prints the version to stdout" do
|
7
|
-
result = execute("vagrant", "version")
|
8
|
-
result.stdout.should match_output(:version, config.vagrant_version)
|
9
|
-
end
|
10
|
-
|
11
6
|
it "prints the version when called with '-v'" do
|
12
7
|
result = execute("vagrant", "-v")
|
13
8
|
result.stdout.should match_output(:version, config.vagrant_version)
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "pathname"
|
3
|
+
|
4
|
+
require "log4r"
|
5
|
+
|
6
|
+
require "support/tempdir"
|
7
|
+
|
8
|
+
# This class manages an isolated environment for Vagrant to
|
9
|
+
# run in. It creates a temporary directory to act as the
|
10
|
+
# working directory as well as sets a custom home directory.
|
11
|
+
#
|
12
|
+
# This class also provides various helpers to create Vagrantfiles,
|
13
|
+
# boxes, etc.
|
14
|
+
class IsolatedEnvironment
|
15
|
+
attr_reader :homedir
|
16
|
+
attr_reader :workdir
|
17
|
+
|
18
|
+
# Initializes an isolated environment. You can pass in some
|
19
|
+
# options here to configure runing custom applications in place
|
20
|
+
# of others as well as specifying environmental variables.
|
21
|
+
#
|
22
|
+
# @param [Hash] apps A mapping of application name (such as "vagrant")
|
23
|
+
# to an alternate full path to the binary to run.
|
24
|
+
# @param [Hash] env Additional environmental variables to inject
|
25
|
+
# into the execution environments.
|
26
|
+
def initialize
|
27
|
+
@logger = Log4r::Logger.new("test::isolated_environment")
|
28
|
+
|
29
|
+
# Create a temporary directory for our work
|
30
|
+
@tempdir = Tempdir.new("vagrant")
|
31
|
+
@logger.info("Initialize isolated environment: #{@tempdir.path}")
|
32
|
+
|
33
|
+
# Setup the home and working directories
|
34
|
+
@homedir = Pathname.new(File.join(@tempdir.path, "home"))
|
35
|
+
@workdir = Pathname.new(File.join(@tempdir.path, "work"))
|
36
|
+
|
37
|
+
@homedir.mkdir
|
38
|
+
@workdir.mkdir
|
39
|
+
end
|
40
|
+
|
41
|
+
# This closes the environment by cleaning it up.
|
42
|
+
def close
|
43
|
+
@logger.info("Removing isolated environment: #{@tempdir.path}")
|
44
|
+
FileUtils.rm_rf(@tempdir.path)
|
45
|
+
end
|
46
|
+
end
|
File without changes
|
data/test/unit/base.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "rspec/autorun"
|
3
|
+
|
4
|
+
# Require Vagrant itself so we can reference the proper
|
5
|
+
# classes to test.
|
6
|
+
require "vagrant"
|
7
|
+
|
8
|
+
# Add the test directory to the load path
|
9
|
+
$:.unshift File.expand_path("../../", __FILE__)
|
10
|
+
|
11
|
+
# Load in helpers
|
12
|
+
require "unit/support/shared/base_context"
|
13
|
+
|
14
|
+
# Do not buffer output
|
15
|
+
$stdout.sync = true
|
16
|
+
$stderr.sync = true
|
17
|
+
|
18
|
+
# Configure RSpec
|
19
|
+
RSpec.configure do |c|
|
20
|
+
c.expect_with :rspec, :stdlib
|
21
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "pathname"
|
3
|
+
|
4
|
+
require "log4r"
|
5
|
+
|
6
|
+
require "support/isolated_environment"
|
7
|
+
|
8
|
+
module Unit
|
9
|
+
class IsolatedEnvironment < ::IsolatedEnvironment
|
10
|
+
def create_vagrant_env(options=nil)
|
11
|
+
options = {
|
12
|
+
:cwd => @workdir,
|
13
|
+
:home_path => @homedir
|
14
|
+
}.merge(options || {})
|
15
|
+
|
16
|
+
Vagrant::Environment.new(options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def vagrantfile(contents, root=nil)
|
20
|
+
root ||= @workdir
|
21
|
+
root.join("Vagrantfile").open("w+") do |f|
|
22
|
+
f.write(contents)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def box(name, vagrantfile_contents="")
|
27
|
+
box_dir = boxes_dir.join(name)
|
28
|
+
box_dir.mkpath
|
29
|
+
vagrantfile(vagrantfile_contents, box_dir)
|
30
|
+
box_dir
|
31
|
+
end
|
32
|
+
|
33
|
+
def boxes_dir
|
34
|
+
dir = @homedir.join("boxes")
|
35
|
+
dir.mkpath
|
36
|
+
dir
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "tempfile"
|
2
|
+
|
3
|
+
require "unit/support/isolated_environment"
|
4
|
+
|
5
|
+
shared_context "unit" do
|
6
|
+
# This creates an isolated environment so that Vagrant doesn't
|
7
|
+
# muck around with your real system during unit tests.
|
8
|
+
#
|
9
|
+
# The returned isolated environment has a variety of helper
|
10
|
+
# methods on it to easily create files, Vagrantfiles, boxes,
|
11
|
+
# etc.
|
12
|
+
def isolated_environment
|
13
|
+
env = Unit::IsolatedEnvironment.new
|
14
|
+
yield env if block_given?
|
15
|
+
env
|
16
|
+
end
|
17
|
+
|
18
|
+
# This helper creates a temporary file and returns a Pathname
|
19
|
+
# object pointed to it.
|
20
|
+
def temporary_file(contents=nil)
|
21
|
+
f = Tempfile.new("vagrant-unit")
|
22
|
+
|
23
|
+
if contents
|
24
|
+
f.write(contents)
|
25
|
+
f.flush
|
26
|
+
end
|
27
|
+
|
28
|
+
return Pathname.new(f.path)
|
29
|
+
end
|
30
|
+
end
|