diff --git a/README.md b/README.md index fa63924066..345615944a 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ BATS (use that link). Then run `./script/build` to generate the binary. Once you have the binary, you can run test against a specified driver: ``` -$ bats integration-tests/driver-virtualbox.bats +$ bats test/integration/driver-virtualbox.bats ✓ virtualbox: machine should not exist ✓ virtualbox: VM should not exist ✓ virtualbox: create @@ -154,7 +154,7 @@ $ bats integration-tests/driver-virtualbox.bats You can also run the general `cli` tests: ``` -$ bats integration-tests/cli.bats +$ bats test/integration/cli.bats ✓ cli: show info ✓ cli: show active help ✓ cli: show config help diff --git a/integration-tests/test.go b/integration-tests/test.go deleted file mode 100644 index 2f26ddc139..0000000000 --- a/integration-tests/test.go +++ /dev/null @@ -1,2 +0,0 @@ -// stub for coverage -package test diff --git a/integration-tests/vars.bash b/integration-tests/vars.bash deleted file mode 100644 index fafd8ead6e..0000000000 --- a/integration-tests/vars.bash +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -PLATFORM=`uname -s | tr '[:upper:]' '[:lower:]'` -ARCH=`uname -m` - -if [ "$ARCH" = "x86_64" ]; then - ARCH="amd64" -else - ARCH="386" -fi - -function machine() { - ./docker-machine_$PLATFORM-$ARCH $@ -} diff --git a/script/generate-coverage b/script/generate-coverage index a3dc5c59bc..cd7173d494 100755 --- a/script/generate-coverage +++ b/script/generate-coverage @@ -41,7 +41,7 @@ fi # Script will bomb out on some dirs if there are no buildable source files, # we shouldn't be checking these anyway so skip over them. -EXCLUDED_DIRS="${DIR}/Godeps ${DIR}/integration-tests ${DIR}/docs ${DIR}/script" +EXCLUDED_DIRS="${DIR}/Godeps ${DIR}/test ${DIR}/docs ${DIR}/script" generate_coverage_for_dir ${DIR} echo "Done checking and generating coverage!" diff --git a/integration-tests/.gitignore b/test/integration/.gitignore similarity index 100% rename from integration-tests/.gitignore rename to test/integration/.gitignore diff --git a/integration-tests/cli.bats b/test/integration/cli.bats similarity index 67% rename from integration-tests/cli.bats rename to test/integration/cli.bats index 75cc8653d7..c18b5740a9 100644 --- a/integration-tests/cli.bats +++ b/test/integration/cli.bats @@ -1,106 +1,106 @@ #!/usr/bin/env bats -load vars +load helpers @test "cli: show info" { - run ./docker-machine_$PLATFORM-$ARCH + run machine [ "$status" -eq 0 ] [[ ${lines[0]} =~ "NAME:" ]] [[ ${lines[1]} =~ "Create and manage machines running Docker" ]] } @test "cli: show active help" { - run ./docker-machine_$PLATFORM-$ARCH active -h + run machine active -h [ "$status" -eq 0 ] [[ ${lines[3]} =~ "command active" ]] } @test "cli: show config help" { - run ./docker-machine_$PLATFORM-$ARCH config -h + run machine config -h [ "$status" -eq 0 ] [[ ${lines[3]} =~ "command config" ]] } @test "cli: show inspect help" { - run ./docker-machine_$PLATFORM-$ARCH inspect -h + run machine inspect -h [ "$status" -eq 0 ] [[ ${lines[3]} =~ "command inspect" ]] } @test "cli: show ip help" { - run ./docker-machine_$PLATFORM-$ARCH ip -h + run machine ip -h [ "$status" -eq 0 ] [[ ${lines[3]} =~ "command ip" ]] } @test "cli: show kill help" { - run ./docker-machine_$PLATFORM-$ARCH kill -h + run machine kill -h [ "$status" -eq 0 ] [[ ${lines[3]} =~ "command kill" ]] } @test "cli: show ls help" { - run ./docker-machine_$PLATFORM-$ARCH ls -h + run machine ls -h [ "$status" -eq 0 ] [[ ${lines[3]} =~ "command ls" ]] } @test "cli: show restart help" { - run ./docker-machine_$PLATFORM-$ARCH restart -h + run machine restart -h [ "$status" -eq 0 ] [[ ${lines[3]} =~ "command restart" ]] } @test "cli: show rm help" { - run ./docker-machine_$PLATFORM-$ARCH rm -h + run machine rm -h [ "$status" -eq 0 ] [[ ${lines[3]} =~ "command rm" ]] } @test "cli: show env help" { - run ./docker-machine_$PLATFORM-$ARCH env -h + run machine env -h [ "$status" -eq 0 ] [[ ${lines[3]} =~ "command env" ]] } @test "cli: show ssh help" { - run ./docker-machine_$PLATFORM-$ARCH ssh -h + run machine ssh -h [ "$status" -eq 0 ] [[ ${lines[3]} =~ "command ssh" ]] } @test "cli: show start help" { - run ./docker-machine_$PLATFORM-$ARCH start -h + run machine start -h [ "$status" -eq 0 ] [[ ${lines[3]} =~ "command start" ]] } @test "cli: show stop help" { - run ./docker-machine_$PLATFORM-$ARCH stop -h + run machine stop -h [ "$status" -eq 0 ] [[ ${lines[3]} =~ "command stop" ]] } @test "cli: show upgrade help" { - run ./docker-machine_$PLATFORM-$ARCH upgrade -h + run machine upgrade -h [ "$status" -eq 0 ] [[ ${lines[3]} =~ "command upgrade" ]] } @test "cli: show url help" { - run ./docker-machine_$PLATFORM-$ARCH url -h + run machine url -h [ "$status" -eq 0 ] [[ ${lines[3]} =~ "command url" ]] } @test "flag: show version" { - run ./docker-machine_$PLATFORM-$ARCH -v + run machine -v [ "$status" -eq 0 ] [[ ${lines[0]} =~ "version" ]] } @test "flag: show help" { - run ./docker-machine_$PLATFORM-$ARCH --help + run machine --help [ "$status" -eq 0 ] [[ ${lines[0]} =~ "NAME" ]] } diff --git a/integration-tests/driver-amazonec2.bats b/test/integration/driver-amazonec2.bats similarity index 99% rename from integration-tests/driver-amazonec2.bats rename to test/integration/driver-amazonec2.bats index f71c96f922..6c55e7aeb0 100644 --- a/integration-tests/driver-amazonec2.bats +++ b/test/integration/driver-amazonec2.bats @@ -1,6 +1,6 @@ #!/usr/bin/env bats -load vars +load helpers export DRIVER=amazonec2 export NAME="bats-$DRIVER-test" diff --git a/integration-tests/driver-azure.bats b/test/integration/driver-azure.bats similarity index 99% rename from integration-tests/driver-azure.bats rename to test/integration/driver-azure.bats index 82514dece5..fcfa7b35ff 100644 --- a/integration-tests/driver-azure.bats +++ b/test/integration/driver-azure.bats @@ -1,6 +1,6 @@ #!/usr/bin/env bats -load vars +load helpers export DRIVER=azure export NAME="bats-$DRIVER-test" diff --git a/integration-tests/driver-digitalocean.bats b/test/integration/driver-digitalocean.bats similarity index 99% rename from integration-tests/driver-digitalocean.bats rename to test/integration/driver-digitalocean.bats index dc3c07acf1..86b582301f 100644 --- a/integration-tests/driver-digitalocean.bats +++ b/test/integration/driver-digitalocean.bats @@ -1,6 +1,6 @@ #!/usr/bin/env bats -load vars +load helpers export DRIVER=digitalocean export NAME="bats-$DRIVER-test" diff --git a/integration-tests/driver-google.bats b/test/integration/driver-google.bats similarity index 99% rename from integration-tests/driver-google.bats rename to test/integration/driver-google.bats index 614b4108eb..bcfdb97f57 100644 --- a/integration-tests/driver-google.bats +++ b/test/integration/driver-google.bats @@ -1,6 +1,6 @@ #!/usr/bin/env bats -load vars +load helpers export DRIVER=google export NAME="bats-$DRIVER-test" diff --git a/integration-tests/driver-hyperv.bats b/test/integration/driver-hyperv.bats similarity index 99% rename from integration-tests/driver-hyperv.bats rename to test/integration/driver-hyperv.bats index 8f5536f6a2..696fe730ce 100644 --- a/integration-tests/driver-hyperv.bats +++ b/test/integration/driver-hyperv.bats @@ -1,6 +1,6 @@ #!/usr/bin/env bats -load vars +load helpers export DRIVER=hyperv export NAME="bats-$DRIVER-test" diff --git a/integration-tests/driver-rackspace.bats b/test/integration/driver-rackspace.bats similarity index 99% rename from integration-tests/driver-rackspace.bats rename to test/integration/driver-rackspace.bats index 8278d22ab4..1d5a63ea7a 100644 --- a/integration-tests/driver-rackspace.bats +++ b/test/integration/driver-rackspace.bats @@ -1,6 +1,6 @@ #!/usr/bin/env bats -load vars +load helpers export DRIVER=rackspace export NAME="bats-$DRIVER-test" diff --git a/integration-tests/driver-softlayer.bats b/test/integration/driver-softlayer.bats similarity index 99% rename from integration-tests/driver-softlayer.bats rename to test/integration/driver-softlayer.bats index 51fb3f3a05..06af7aeb81 100644 --- a/integration-tests/driver-softlayer.bats +++ b/test/integration/driver-softlayer.bats @@ -1,6 +1,6 @@ #!/usr/bin/env bats -load vars +load helpers export DRIVER=softlayer export NAME="bats-$DRIVER-test" diff --git a/integration-tests/driver-virtualbox.bats b/test/integration/driver-virtualbox.bats similarity index 99% rename from integration-tests/driver-virtualbox.bats rename to test/integration/driver-virtualbox.bats index b179b4e345..e7ba6b3e21 100644 --- a/integration-tests/driver-virtualbox.bats +++ b/test/integration/driver-virtualbox.bats @@ -1,6 +1,6 @@ #!/usr/bin/env bats -load vars +load helpers export DRIVER=virtualbox export NAME="bats-$DRIVER-test" diff --git a/integration-tests/driver-vmwarefusion.bats b/test/integration/driver-vmwarefusion.bats similarity index 99% rename from integration-tests/driver-vmwarefusion.bats rename to test/integration/driver-vmwarefusion.bats index 0092d2bc8b..fef28dc4a2 100644 --- a/integration-tests/driver-vmwarefusion.bats +++ b/test/integration/driver-vmwarefusion.bats @@ -1,6 +1,6 @@ #!/usr/bin/env bats -load vars +load helpers export DRIVER=vmwarefusion export NAME="bats-$DRIVER-test" diff --git a/integration-tests/driver-vmwarevcloudair.bats b/test/integration/driver-vmwarevcloudair.bats similarity index 99% rename from integration-tests/driver-vmwarevcloudair.bats rename to test/integration/driver-vmwarevcloudair.bats index d8e4f884da..ef4e0dc5b1 100644 --- a/integration-tests/driver-vmwarevcloudair.bats +++ b/test/integration/driver-vmwarevcloudair.bats @@ -1,6 +1,6 @@ #!/usr/bin/env bats -load vars +load helpers export DRIVER=vmwarevcloudair export NAME="bats-$DRIVER-test" diff --git a/test/integration/helpers.bash b/test/integration/helpers.bash new file mode 100644 index 0000000000..591412a694 --- /dev/null +++ b/test/integration/helpers.bash @@ -0,0 +1,29 @@ +#!/bin/bash + +# Root directory of the repository. +MACHINE_ROOT=${BATS_TEST_DIRNAME}/../.. + +PLATFORM=`uname -s | tr '[:upper:]' '[:lower:]'` +ARCH=`uname -m` + +if [ "$ARCH" = "x86_64" ]; then + ARCH="amd64" +else + ARCH="386" +fi +MACHINE_BIN_NAME=docker-machine_$PLATFORM-$ARCH + +build_machine() { + pushd $MACHINE_ROOT >/dev/null + godep go build -o $MACHINE_BIN_NAME + popd >/dev/null +} + +# build machine binary if needed +if [ ! -e $MACHINE_ROOT/$MACHINE_BIN_NAME ]; then + build_machine +fi + +function machine() { + ${MACHINE_ROOT}/$MACHINE_BIN_NAME "$@" +}