@@ -11,7 +11,12 @@ source "${PROGDIR}/.util/tools.sh"
1111# shellcheck source=SCRIPTDIR/.util/print.sh
1212source " ${PROGDIR} /.util/print.sh"
1313
14+ # shellcheck source=SCRIPTDIR/.util/builders.sh
15+ source " ${PROGDIR} /.util/builders.sh"
16+
1417function main() {
18+ local builderArray
19+ builderArray=()
1520 while [[ " ${# } " != 0 ]]; do
1621 case " ${1} " in
1722 --help|-h)
@@ -20,6 +25,11 @@ function main() {
2025 exit 0
2126 ;;
2227
28+ --builder|-b)
29+ builderArray+=(" ${2} " )
30+ shift 2
31+ ;;
32+
2333 " " )
2434 # skip if the argument is empty
2535 shift 1
@@ -35,8 +45,32 @@ function main() {
3545 fi
3646
3747 tools::install
38- images::pull
39- tests::run
48+
49+ if [ ${# builderArray[@]} -eq 0 ]; then
50+ util::print::title " No builders provided. Finding builders in integration.json..."
51+
52+ local builders
53+ builders=" $( util::builders::list " ${BUILDPACKDIR} /integration.json" | jq -r ' .[]' ) "
54+
55+ # shellcheck disable=SC2206
56+ IFS=$' \n ' builderArray=(${builders} )
57+ unset IFS
58+ fi
59+
60+ # shellcheck disable=SC2068
61+ images::pull ${builderArray[@]}
62+
63+ local testout
64+ testout=$( mktemp)
65+ for builder in " ${builderArray[@]} " ; do
66+ util::print::title " Setting default pack builder image..."
67+ pack config default-builder " ${builder} "
68+
69+ tests::run " ${builder} " " ${testout} "
70+ done
71+
72+ util::tools::tests::checkfocus " ${testout} "
73+ util::print::success " ** GO Test Succeeded with all builders**"
4074}
4175
4276function usage() {
@@ -46,7 +80,9 @@ integration.sh [OPTIONS]
4680Runs the integration test suite.
4781
4882OPTIONS
49- --help -h prints the command usage
83+ --help -h prints the command usage
84+ --builder <name> -b <name> sets the name of the builder(s) that are pulled / used for testing.
85+ Defaults to "builders" array in integration.json, if present.
5086USAGE
5187}
5288
@@ -59,22 +95,7 @@ function tools::install() {
5995}
6096
6197function images::pull() {
62- local builders
63- builders=" "
64-
65- if [[ -f " ${BUILDPACKDIR} /integration.json" ]]; then
66- builders=" $( jq -r .builder " ${BUILDPACKDIR} /integration.json" ) "
67-
68- if [[ " ${builders} " == " null" || -z " ${builders} " ]]; then
69- builders=" $( jq -r ' select(.builders != null) | .builders[]' " ${BUILDPACKDIR} /integration.json" ) "
70- fi
71- fi
72-
73- if [[ " ${builders} " == " null" || -z " ${builders} " ]]; then
74- builders=" index.docker.io/paketobuildpacks/builder:buildpackless-base"
75- fi
76-
77- while read -r builder; do
98+ for builder in " ${@ } " ; do
7899 util::print::title " Pulling builder image ${builder} ..."
79100 docker pull " ${builder} "
80101
@@ -93,24 +114,19 @@ function images::pull() {
93114
94115 util::print::title " Pulling lifecycle image..."
95116 docker pull " ${lifecycle_image} "
96- done <<< " ${builders}"
97-
98- util::print::title " Setting default pack builder image..."
99- local default
100- read -r default <<< " ${builders}"
101- pack config default-builder " ${default} "
117+ done
102118}
103119
104120function tests::run() {
105121 util::print::title " Run Buildpack Runtime Integration Tests"
122+ util::print::info " Using ${1} as builder..."
106123
107- testout=$( mktemp)
108124 pushd " ${BUILDPACKDIR} " > /dev/null
109- if GOMAXPROCS= " ${GOMAXPROCS :- 4} " go test -count=1 -timeout 0 ./integration/... -v -run Integration | tee " ${testout} " ; then
110- util::tools::tests::checkfocus " ${testout} "
111- util::print::success " ** GO Test Succeeded **"
125+ # shellcheck disable=SC2068
126+ if GOMAXPROCS= " ${GOMAXPROCS :- 4} " go test -count=1 -timeout 0 ./integration/... -v -run Integration | tee " ${2} " ; then
127+ util::print::info " ** GO Test Succeeded with ${1} **"
112128 else
113- util::print::error " ** GO Test Failed **"
129+ util::print::error " ** GO Test Failed with ${1} **"
114130 fi
115131 popd > /dev/null
116132}
0 commit comments