diff --git a/bin/compile b/bin/compile index 556a828..ca2ebed 100755 --- a/bin/compile +++ b/bin/compile @@ -14,6 +14,10 @@ echo "Info: CACHE_DIR=$CACHE_DIR" if [ "$BUILDPACK_GHC_BASE_URL" != "" ]; then arch=$(uname -m) ghcver=$GHC_BOOTSTRAP_VERSION + if [ "$ghcver" == "" ]; then + echo "Error: please set GHC_BOOTSTRAP_VERSION"; + exit 1; + fi; bsdir=$CACHE_DIR/bootstrap ghcurl="$BUILDPACK_GHC_BASE_URL/$ghcver/ghc-$ghcver-$arch-unknown-linux.tar.bz2" echo "Info: bootstrap directory: ${bsdir}"; diff --git a/features/compile.feature b/features/compile.feature new file mode 100644 index 0000000..6bc7667 --- /dev/null +++ b/features/compile.feature @@ -0,0 +1,31 @@ +Feature: Compile + + In order to build and deploy an application + As the bin/compile script of the buildpack + I want to download and bootstrap the environment + + Scenario: BUILDPACK_GHC_BASE_URL not set + Given environment variable BUILDPACK_GHC_BASE_URL is set to "" + When I run `compile ../tmp/build ../tmp/cache` + Then the output should contain "Error: please set BUILDPACK_GHC_BASE_URL" + And the exit status should be 1 + + Scenario: BUILDPACK_GHC_BASE_URL is set + Given environment variable BUILDPACK_GHC_BASE_URL is set to "http://www.haskell.org/ghc/dist" + When I run `compile ../tmp/build ../tmp/cache` + Then the output should not contain "Error: please set BUILDPACK_GHC_BASE_URL" + And the exit status should be 0 + + Scenario: GHC_BOOTSTRAP_VERSION is not set + Given environment variable GHC_BOOTSTRAP_VERSION is set to "" + Given environment variable BUILDPACK_GHC_BASE_URL is set to "http://www.haskell.org/ghc/dist" + When I run `compile ../tmp/build ../tmp/cache` + Then the output should contain "Error: please set GHC_BOOTSTRAP_VERSION" + And the exit status should be 1 + + Scenario: GHC_BOOTSTRAP_VERSION is set + Given environment variable GHC_BOOTSTRAP_VERSION is set to "7.0.4" + Given environment variable BUILDPACK_GHC_BASE_URL is set to "http://www.haskell.org/ghc/dist" + When I run `compile ../tmp/build ../tmp/cache` + Then the output should not contain "Error: please set GHC_BOOTSTRAP_VERSION" + And the exit status should be 0 diff --git a/features/step_definitions/core.rb b/features/step_definitions/core.rb index e69de29..fea857f 100644 --- a/features/step_definitions/core.rb +++ b/features/step_definitions/core.rb @@ -0,0 +1,5 @@ + +Given /^environment variable (.*) is set to "([^"]*)"$/ do |name, value| + ENV[name]=value +end +