Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds pre_create_command for running arbitrary commands #1243

Merged
merged 1 commit into from Oct 23, 2017

Conversation

sean797
Copy link
Contributor

@sean797 sean797 commented Jun 29, 2017

This allows .kitchen.yml to contains the following:

driver:
  pre_create_command: echo 'this runs before an instance is created'

Adding this to core since the discussion at test-kitchen/kitchen-docker#249 kitchen-vagrant already has this functionally, but this adds it to all drivers.

Copy link
Contributor

@coderanger coderanger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be using the mixlib-shellout wrapper method like everything else.

@sean797 sean797 force-pushed the pre_create_command branch 2 times, most recently from 9db113c to 4e8fd2d Compare October 6, 2017 17:46
@sean797
Copy link
Contributor Author

sean797 commented Oct 6, 2017

Thanks for taking a look @coderanger. Updated, rebased and add some tests since tests are now passing 👍

@@ -88,6 +88,18 @@ class Slow < Base
end
end

describe ".pre_create_command" do
it "run command" do
config[:pre_create_command] = "echo works 2&>1 > /dev/null"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail on Windows. You can use driver.expects(:run_command).with("echo works 2&>1 > /dev/null") to avoid actually running anything. Similarly with the fail test, that one is more technically okay but just for unit test speed it would be nice to use Mocha to stub it raising the exception rather than actually running a failed command :)

This allows .kitchen.yml to contains the following:

```yaml
driver:
  pre_create_command: echo 'this runs before a instance is created'
```
@sean797
Copy link
Contributor Author

sean797 commented Oct 6, 2017

Ugh Windows... Anyway updated and test are 🍏

Copy link
Contributor

@coderanger coderanger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, will leave this open for a bit in case @cheeseplus wants to review too and he is music-ing for a few days. Thanks for the patch!

@cheeseplus cheeseplus merged commit 9cc8241 into test-kitchen:master Oct 23, 2017
@coderanger coderanger mentioned this pull request Nov 1, 2017
@test-kitchen test-kitchen locked and limited conversation to collaborators Mar 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants