50 lines
1.7 KiB
Bash
Executable File
50 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# Copyright (c) 2012-2017 Red Hat, Inc
|
|
# All rights reserved. This program and the accompanying materials
|
|
# are made available under the terms of the Eclipse Public License v1.0
|
|
# which accompanies this distribution, and is available at
|
|
# http://www.eclipse.org/legal/epl-v10.html
|
|
#
|
|
# Contributors:
|
|
# Marian Labuda - Initial Implementation
|
|
|
|
BATS_BASE_DIR=$(cd "$(dirname "$0")"/..; pwd)
|
|
. "${BATS_BASE_DIR}"/build.include
|
|
BATS_BASE_DIR=$(get_mount_path "${BATS_BASE_DIR}")
|
|
|
|
init "$@"
|
|
IMAGE_NAME="eclipse/che-bats:$TAG"
|
|
|
|
DOCKER_RUN_OPTIONS=""
|
|
BATS_OPTIONS=""
|
|
# run bats with terminal mode (pretty print) if supported by current shell
|
|
if [ -t 1 ]; then
|
|
DOCKER_RUN_OPTIONS="-t"
|
|
BATS_OPTIONS="--pretty"
|
|
else
|
|
BATS_OPTIONS="--tap"
|
|
fi
|
|
|
|
# Runs functional CLI tests in a docker container.
|
|
# Pass a file name of functional bats tests as an argument.
|
|
# The file has to be placed in tests folder in directory containing this script
|
|
# (Optional) second argument is options for a docker run command.
|
|
run_test_in_docker_container() {
|
|
docker_exec run --rm ${DOCKER_RUN_OPTIONS} $2 \
|
|
-v "${BATS_BASE_DIR}":/dockerfiles \
|
|
-e CLI_IMAGE_TAG=$TAG \
|
|
-e BATS_BASE_DIR="${BATS_BASE_DIR}" \
|
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
$IMAGE_NAME bats ${BATS_OPTIONS} /dockerfiles/cli/tests/$1
|
|
}
|
|
|
|
|
|
echo "Running tests in container from image $IMAGE_NAME"
|
|
echo "Running functional bats tests for CLI prompts and usage"
|
|
run_test_in_docker_container cli_prompts_usage_tests.bats
|
|
echo "Running functional bats tests for init and destroy commands"
|
|
run_test_in_docker_container cmd_init_destroy_tests.bats
|
|
echo "Running functionals bats tests for start command"
|
|
run_test_in_docker_container cmd_start_tests.bats --net=host
|
|
|