Bats tests exection fixes

- allows to skip via skipTests
- runs bats tests only on linux

fixes gh-129 gh-130
This commit is contained in:
Marcin Grzejszczak
2019-04-16 07:32:01 +04:00
parent 39ad014510
commit c6c8c762c5
2 changed files with 37 additions and 41 deletions

View File

@@ -29,29 +29,13 @@
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution><!-- Run our version calculation script -->
<id>Run tests</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${basedir}/src/test/bash/run-bats.sh</executable>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>docs</id>
<build>
<plugins>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
@@ -71,5 +55,35 @@
</plugins>
</build>
</profile>
<profile>
<id>unix</id>
<activation>
<os>
<family>unix</family>
<name>Linux</name>
</os>
</activation>
<build>
<plugins>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution>
<id>Run tests</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
<executable>${basedir}/src/test/bash/run-bats.sh</executable>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@@ -20,25 +20,13 @@ if [[ $# -ne 1 ]]; then
usage
fi
function shellcheck_installed() {
shellcheck --version && return 0 || return 1
}
SHELLCHECK_VERSION="v0.6.0"
SHELLCHECK_INSTALLED="$( shellcheck_installed && echo "true" || echo "false" )"
echo "Shellcheck installed? [${SHELLCHECK_INSTALLED}]"
if [[ "${SHELLCHECK_INSTALLED}" != "false" ]]; then
SHELLCHECK_BIN="shellcheck"
else
SHELLCHECK_BIN="${ROOT_DIR}/../target/shellcheck-${SHELLCHECK_VERSION}/shellcheck"
fi
echo "Shellcheck binary location [${SHELLCHECK_BIN}]"
SHELLCHECK_BIN="${ROOT_DIR}/../target/shellcheck-${SHELLCHECK_VERSION}/shellcheck"
case $1 in
download-shellcheck)
if [[ "${OSTYPE}" == linux* && ! -z "${SHELLCHECK_BIN}" && "${SHELLCHECK_INSTALLED}" == "false" ]]; then
if [[ "${OSTYPE}" == linux* && ! -z "${SHELLCHECK_BIN}" ]]; then
SHELLCHECK_ARCHIVE="shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz"
SHELLCHECK_ARCHIVE_SHA512SUM="d88733e95aea8e970c373a3f677a3eb272f14c12d3e9c93f81463b5fe406b43acdd3046d10c092f40c070a96a5fac1cf7e18b35ed790d76ecced6af32e2c8a85"
if [[ -x "${ROOT_DIR}/../target/shellcheck-${SHELLCHECK_VERSION}/shellcheck" ]]; then
echo "shellcheck already downloaded - skipping..."
exit 0
@@ -46,24 +34,18 @@ case $1 in
wget -P "${ROOT_DIR}/../target/" \
"https://storage.googleapis.com/shellcheck/${SHELLCHECK_ARCHIVE}"
pushd "${ROOT_DIR}/../target/"
echo "${SHELLCHECK_ARCHIVE_SHA512SUM} ${SHELLCHECK_ARCHIVE}" | sha512sum -c -
tar xvf "${SHELLCHECK_ARCHIVE}"
rm -vf -- "${SHELLCHECK_ARCHIVE}"
popd
else
if [[ "${SHELLCHECK_INSTALLED}" == "false" ]]; then
echo "It seems that automatic installation is not supported on your platform."
echo "Please install shellcheck manually:"
echo " https://github.com/koalaman/shellcheck#installing"
exit 1
fi
echo "It seems that automatic installation is not supported on your platform."
echo "Please install shellcheck manually:"
echo " https://github.com/koalaman/shellcheck#installing"
exit 1
fi
;;
run-shellcheck)
echo "Running shellcheck"
if [[ "${SHELLCHECK_INSTALLED}" != "false" ]]; then
SHELLCHECK_BIN="shellcheck"
fi
"${SHELLCHECK_BIN}" "${ROOT_DIR}"/src/main/asciidoc/*.sh
echo "Shellcheck passed sucessfully!"
;;