114 Commits

Author SHA1 Message Date
Brian Cain
eb3e309f89
Ensure guest names are string when filtering
Prior to this commit, if a guest name was given as a symbol, the
filter_triggers method would fail to properly match it with the only_on
option, as it is not a valid type to the #String.match method. This
commit fixes that by converting the parameter to a string so that it can
be properly matched on the guest.
2019-05-13 14:07:22 -07:00
Brian Cain
35ee3e2342
Fixes #10823: Use Process.exit! for abort trigger option
Prior to this commit, the `abort` option for triggers would just call
`exit`, which would end up raising a SystemExit exception, signaling
Vagrant to abort. This broke down however in a multithreaded context
like when running multiple guests at once on supported providers,
resulting in Vagrant failing to exit cleanly and instead raise an
exception. This commit changes that by instead using `Process.exit!` to
abort Vagrant.
2019-05-03 14:48:54 -07:00
Brian Cain
16b5ad74ca
Handle command triggers with run_remote options
This commit adds some handling around when a machine does not exist at
all but a trigger was defined with a run_remote option
2019-02-01 13:34:15 -08:00
Brian Cain
fefb702359
Introduce type and command triggers
This commit introduces some basic functionality for typed triggers:

- command
- action

Command triggers are triggers that will run before or after a given
sub-command.

Action triggers are for running triggers before or after internal
actions for Vagrant. This could be before or after a provision step,
before or after synced folders, or networking, etc.
2019-02-01 13:34:15 -08:00
Brian Cain
69b3b44505
Fixes #10393: Only use Shellwords on non-windows hosts
This commit updates how the trigger `run` inline option works by only
applying `Shellwords.split` to the inline command if it is going to be
run on non-Windows hosts. Otherwise pass the inline script directly to
be executed by Powershell.
2018-11-13 13:07:39 -08:00
Brian Cain
f4d618eb58
Fixes #9840: Introduce ruby option for trigger
This commit introduces a new option to the core trigger feature: `ruby`.
It can be defined to run ruby code when the trigger is configured to
fire. If you give the ruby block an env and machine argument, the
defined ruby code can use those variables internally.
2018-10-05 12:53:41 -07:00
Brian Cain
58ebd52f99
Add abort option to core triggers
This commit adds a new option `abort`, which when configured, will exit
the Vagrant process completely. If set to `true`, it will exit cleanly
with exit code 0. Otherwise, the exit code can be configured.
2018-09-25 09:40:36 -07:00
Chris Roberts
3ace82cc5b Update Vagrant.has_plugin? helper to function prior to plugin loading
Due to the Vagrantfile being loaded prior to plugin loading to determine
project local plugin information the Vagrant.has_plugin? helper will always
return false when the Vagrantfile is first loaded. To prevent this behavior
we can check for plugins in the plugin data files prior to the plugins
being loaded, and after they have been loaded we can fallback to the
original specification based check.
2018-08-31 14:03:42 -07:00
Brian Cain
5723c7181a
Add test for trigger run path with spaces 2018-08-17 15:17:49 -07:00
Brian Cain
8bce4f3828
Update tests to include passed in arg values 2018-08-14 13:24:42 -07:00
Brian Cain
29aba535ce
(#10104) Ensure trigger run args are an array prior to join
Prior to this commit, if the args key was a string rather than an array
of strings, the `join` command would fail when appending the arguments
to the run command for a given script. This commit updates that by
ensuring the `args` option is an array prior to joining the arguments.
2018-08-14 10:29:51 -07:00
Chris Roberts
3e22764ac8 Add test coverage on globalize and localize within plugin manager 2018-07-18 10:48:57 -07:00
Chris Roberts
3223737734 Use env_local consistently internally 2018-07-17 14:49:41 -07:00
Chris Roberts
84c0aafe71 Support non-interactive local plugin install 2018-07-17 14:49:41 -07:00
Brian Cain
52c3dcc70e
(#9997) Catch and allow for non-standard exit codes
Prior to this commit, the run trigger option wouldn't catch for failures
outside of the #Subprocess.execute raising exceptions. This commit fixes
that by inspecting the exit code result of the subprocess and using the
new `exit_codes` option to determine how to move forward with the
trigger.
2018-07-09 15:56:26 -07:00
Brian Cain
2000a11042
Add tests for powershell run functions 2018-04-20 10:51:38 -07:00
Brian Cain
e7d07cb110
Add rspec tests for trigger plugin 2018-04-20 10:51:38 -07:00
Brian Cain
6ea7819402
Update rspec tests for trigger plugin 2018-04-20 10:51:38 -07:00
Brian Cain
fbad4c749d
Add basic spec test for trigger class 2018-04-20 10:51:38 -07:00
Brian Cain
8b1043c199 Remove stub methods and replace with allows for rpsec 3 2017-08-04 15:02:59 -07:00
Chris Roberts
1a62743bc5 Update rspec to recent version and fix deprecations 2017-08-03 17:54:07 -07:00
Chris Roberts
97715280c2 Deep merge plugin list with system plugins. Discard specifications correctly. 2017-06-27 19:05:30 -07:00
Chris Roberts
cf93efca2d Update tests for new information and cleaning method 2016-11-16 13:27:34 -08:00
Chris Roberts
3afa7a3193 Update specs to match updated behavior for local install 2016-11-11 15:21:30 -08:00
Chris Roberts
1f5dd35d16 Remove bundler where no longer required 2016-11-07 20:00:38 -08:00
Seth Vargo
fb60d34236
Add unique names to all tmpdir and tempfile calls in tests + cleanup
This commit attempts to uniquely identify the temporary files and
directories that are created during test runs. Where it was a quick
fix, this commit also removes the temporary files and directories.

There are still a ton of temporary files due to calls to
.isolated_environment in the tests without an easy API an easy way
to provide a closer to that function.
2016-05-28 23:22:34 -04:00
Mitchell Hashimoto
85f1e05e2a core: prune machine if non-existent CWD from index [GH-4742] 2015-11-18 15:48:59 -08:00
Mitchell Hashimoto
69d9bc0fe8 Environment can_install_provider and install_provider 2015-11-05 11:50:10 -08:00
Mitchell Hashimoto
e759df11a0 core: fix crash for missing options [GH-5550] 2015-07-06 10:36:41 -06:00
Seth Vargo
f3c35855f0 Add a newline because #ocd 2014-12-08 11:35:11 -08:00
Seth Vargo
7f6a4fa3bd Add tests for plugin manager push_configs 2014-12-08 11:35:11 -08:00
Seth Vargo
60a8472891 Use a pushes registry instead of data hash 2014-12-08 11:35:09 -08:00
Matt Wrock
dc628cd722 fixes infinite loop in machine state call if provider calls machine.action 2014-11-06 08:51:47 -08:00
Kalman Hazins
bb052366f7 Change symbols inside hashes to 1.9 JSON-like syntax 2014-05-22 12:35:12 -04:00
Mitchell Hashimoto
c5b3dbbf75 core: fix final test 2014-05-01 10:12:36 -07:00
Mitchell Hashimoto
429bd73495 core: provider has default priority of 5 2014-05-01 09:26:36 -07:00
Mitchell Hashimoto
d6b7f3a855 Fix tests 2014-04-29 17:02:10 -07:00
Mitchell Hashimoto
e78d087c27 Tests passing 2014-04-21 13:54:59 -07:00
Mitchell Hashimoto
bc2e3727a9 core: Add usable? check to providers 2014-04-21 13:53:07 -07:00
Mitchell Hashimoto
a0e9f46251 core: commands can use the IDs from anywhere to control 2014-04-21 13:51:24 -07:00
Fabio Rehm
54656151cf Convert specs to RSpec 2.14.8 syntax with Transpec
This conversion is done by Transpec 1.10.2 with the following command:
    transpec test/unit/

* 507 conversions
    from: obj.should
      to: expect(obj).to

* 394 conversions
    from: == expected
      to: eq(expected)

* 260 conversions
    from: obj.should_receive(:message)
      to: expect(obj).to receive(:message)

* 85 conversions
    from: obj.stub(:message)
      to: allow(obj).to receive(:message)

* 25 conversions
    from: its(:attr) { }
      to: describe '#attr' do subject { super().attr }; it { } end

* 19 conversions
    from: obj.should_not
      to: expect(obj).not_to

* 7 conversions
    from: obj.should_not_receive(:message)
      to: expect(obj).not_to receive(:message)

* 3 conversions
    from: Klass.any_instance.should_receive(:message)
      to: expect_any_instance_of(Klass).to receive(:message)
2014-03-14 12:02:07 -03:00
Mitchell Hashimoto
4437bcd77f core: better error if attempting to uninstall system plugin 2014-03-03 15:05:32 -08:00
Mitchell Hashimoto
b5637da6c4 core: plugin manager marks system gems as system 2014-03-03 14:55:34 -08:00
Mitchell Hashimoto
efddef0a80 core: add tests fornew systems path for plugin manager 2014-03-03 09:50:16 -08:00
Mitchell Hashimoto
7710fd16fa core: load system plugins if they are installed 2014-03-03 09:44:29 -08:00
Mitchell Hashimoto
d40dc919d8 core: plugin tests no longer obliterate manager 2014-02-06 20:50:51 -08:00
Mitchell Hashimoto
f72db0c611 core: config raises NoMethodError on bad calls once finalized 2014-02-05 16:14:58 -08:00
Mitchell Hashimoto
a924a7b48c core: provider capabilities 2014-01-26 14:15:06 -08:00
Mitchell Hashimoto
f713e43b00 Fix tests for new UI methods 2014-01-17 21:03:02 -08:00
Mitchell Hashimoto
08b1aee00d core: default commands to primary 2014-01-11 09:15:14 -08:00