Commit b84384e0 authored by Ramon Nou's avatar Ramon Nou
Browse files

Remove unused BATS test system

parent ddefccc7
Loading
Loading
Loading
Loading
Loading
+0 −22
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@ variables:
  INTEGRATION_TESTS_BIN_PATH:   "${CI_PROJECT_DIR}/gkfs/install/share/gkfs/tests/integration"
  COVERAGE_PATH:                "${CI_PROJECT_DIR}/gkfs/build/coverage"
  PYTEST:                       "${CI_PROJECT_DIR}/gkfs/install/share/gkfs/tests/integration/pytest-venv/bin/py.test"
  BATS:                         "${CI_PROJECT_DIR}/tests/scripts/bats/bin/bats"
  LD_LIBRARY_PATH:              "${CI_PROJECT_DIR}/deps/install/lib:${CI_PROJECT_DIR}/deps/install/lib64"
  # Configuration variables
  GKFS_LOG_LEVEL:               "100"
@@ -103,27 +102,6 @@ gkfs:
## Testing
################################################################################

## == tests for scripts ====================
scripts:
  stage: test
  image: ${TESTING}
  needs: []
  script:
    - mkdir -p ${BUILD_PATH}/tests/scripts
    - cd ${BUILD_PATH}/tests/scripts
    - ${BATS} -r ${CI_PROJECT_DIR}/tests/scripts/dl_dep.sh --formatter junit
    - ${BATS} -r ${CI_PROJECT_DIR}/tests/scripts/compile_dep.sh --formatter junit
  rules:
    - if: '$CI_MERGE_REQUEST_EVENT_TYPE == "detached"'
      when: never
    - if: '$CI_MERGE_REQUEST_ID != ""'
      when: manual
      allow_failure: true
  artifacts:
    expire_in: 1 day
    reports:
      junit: ${BUILD_PATH}/tests/scripts/report.xml

## == integration tests for gkfs (group 1: I/O, FUSE, shell) ================
gkfs:integration-1:
  stage: test
+0 −12
Original line number Diff line number Diff line
[submodule "tests/scripts/bats"]
	path = tests/scripts/bats
	url = https://github.com/bats-core/bats-core.git
[submodule "tests/scripts/helpers/bats-assert"]
	path = tests/scripts/helpers/bats-assert
	url = https://github.com/bats-core/bats-assert.git
[submodule "tests/scripts/helpers/bats-support"]
	path = tests/scripts/helpers/bats-support
	url = https://github.com/bats-core/bats-support.git
[submodule "tests/scripts/helpers/bats-file"]
	path = tests/scripts/helpers/bats-file
	url = https://github.com/bats-core/bats-file.git
[submodule "external/spdlog"]
	path = external/spdlog
	url = https://github.com/gabime/spdlog
Compare a8b8d0dc to a8b8d0dc
Original line number Diff line number Diff line
Subproject commit a8b8d0dc7a05abe10c8511fe5041c137e06d18bf
+0 −158
Original line number Diff line number Diff line
# vim: set ft=bash:

setup() {
    GIT_ROOTDIR=$(git rev-parse --show-toplevel)
    SCRIPT_TESTDIR=${GIT_ROOTDIR}/tests/scripts/compile_dep.sh

    load "${GIT_ROOTDIR}/tests/scripts/helpers/bats-support/load.bash"
    load "${GIT_ROOTDIR}/tests/scripts/helpers/bats-assert/load.bash"
    load "${GIT_ROOTDIR}/tests/scripts/helpers/bats-file/load.bash"


    # save the current PWD
    pushd . > /dev/null

    # make sure that the script is able to find the profiles
    cd ${GIT_ROOTDIR}/scripts

    # make executables in scripts/ visible to PATH
    PATH="${GIT_ROOTDIR}/scripts:$PATH"
}

teardown() {
    # restore the current PWD
    popd > /dev/null
}

@test "[compile_dep.sh] Check usage" {
    run compile_dep.sh -h
    assert_output --partial "usage: compile_dep.sh"
}

@test "[compile_dep.sh] Check no --profile or --dependency options" {

    expected_output=${SCRIPT_TESTDIR}/latest/default.out

    assert_exist $expected_output

    run compile_dep.sh -n bar baz

    while IFS= read -r line
    do
        assert_output --partial "$line"
    done < "$expected_output"
}

@test "[compile_dep.sh] Check invalid --profile option without SOURCES_PATH or INSTALL_PATH" {
    run -1 compile_dep.sh -p foo
    assert_output --partial "ERROR: Positional arguments missing."
}

@test "[compile_dep.sh] Check invalid --profile option without SOURCES_PATH" {
    run -1 compile_dep.sh -p foo bar
    assert_output --partial "ERROR: Positional arguments missing."
}

@test "[compile_dep.sh] Check unknown --profile option" {

    profile_name=default
    profile_version=latest

    run -1 compile_dep.sh -n -p foobar bar baz

    assert_output --partial "Dependency 'foobar' not found in '$profile_name:$profile_version'"

}

@test "[compile_dep.sh] Check valid --profile option, no PROFILE_NAME or PROFILE_VERSION" {

    dependency_names=($(compile_dep.sh -l default:latest | perl -lne "print for /^\s{4}(\w+(?::\w+)*):.*$/"))

    for dep in "${dependency_names[@]}"; do
        source_path=$(readlink -f ${BATS_TEST_TMPDIR}/foo)
        install_path=$(readlink -f ${BATS_TEST_TMPDIR}/bar)

        run compile_dep.sh -n -p "${dep}" ${source_path} ${install_path}

        assert_output --regexp \
"CORES = [0-9]+ \(default\)
Sources download path = ${source_path}
Installation path = ${install_path}
Profile name: default
Profile version: latest
------------------------------------


######## Installing:  ${dep} ###############################
.*
Done"

    done
}

@test "[compile_dep.sh] Check valid --profile option, PROFILE_NAME only" {

    profile_names=($(compile_dep.sh -l latest | perl -lne "print for /^\* (\w+):.*$/"))

    for pn in "${profile_names[@]}"; do

        dependency_names=($(compile_dep.sh -l ${pn}:latest | perl -lne "print for /^\s{4}(\w+(?::\w+)*):.*$/"))

        for dep in "${dependency_names[@]}"; do
            source_path=$(readlink -f ${BATS_TEST_TMPDIR}/foo)
            install_path=$(readlink -f ${BATS_TEST_TMPDIR}/bar)

            run compile_dep.sh -n -p "${dep}@${pn}" ${source_path} ${install_path}

            assert_output --regexp \
"CORES = [0-9]+ \(default\)
Sources download path = ${source_path}
Installation path = ${install_path}
Profile name: ${pn}
Profile version: latest
------------------------------------


######## Installing:  ${dep} ###############################
.*
Done"

        done
    done
}

@test "[compile_dep.sh] Check valid --profile option, PROFILE_NAME and PROFILE_VERSION" {

    profile_versions=($(compile_dep.sh -l | perl -lne "print for /^\s{2}(.*?):$/"))

    for pv in "${profile_versions[@]}"; do

        profile_names=($(compile_dep.sh -l latest | perl -lne "print for /^\* (\w+):.*$/"))

        for pn in "${profile_names[@]}"; do

            dependency_names=($(compile_dep.sh -l ${pn}:latest | perl -lne "print for /^\s{4}(\w+(?::\w+)*):.*$/"))

            for dep in "${dependency_names[@]}"; do
                source_path=$(readlink -f ${BATS_TEST_TMPDIR}/foo)
                install_path=$(readlink -f ${BATS_TEST_TMPDIR}/bar)

                run compile_dep.sh -n -p "${dep}@${pn}" ${source_path} ${install_path}

                assert_output --regexp \
"CORES = [0-9]+ \(default\)
Sources download path = ${source_path}
Installation path = ${install_path}
Profile name: ${pn}
Profile version: latest
------------------------------------


######## Installing:  ${dep} ###############################
.*
Done"

            done
        done
    done
}

tests/scripts/dl_dep.sh/test.bats

deleted100644 → 0
+0 −144
Original line number Diff line number Diff line
# vim: set ft=bash:

setup() {
    GIT_ROOTDIR=$(git rev-parse --show-toplevel)
    SCRIPT_TESTDIR=${GIT_ROOTDIR}/tests/scripts/dl_dep.sh

    load "${GIT_ROOTDIR}/tests/scripts/helpers/bats-support/load.bash"
    load "${GIT_ROOTDIR}/tests/scripts/helpers/bats-assert/load.bash"
    load "${GIT_ROOTDIR}/tests/scripts/helpers/bats-file/load.bash"


    # save the current PWD
    pushd . > /dev/null

    # make sure that the script is able to find the profiles
    cd ${GIT_ROOTDIR}/scripts

    # make executables in scripts/ visible to PATH
    PATH="${GIT_ROOTDIR}/scripts:$PATH"
}

teardown() {
    # restore the current PWD
    popd > /dev/null
}

@test "[dl_dep.sh] Check usage" {
    run dl_dep.sh -h
    assert_output --partial "usage: dl_dep.sh"
}

@test "[dl_dep.sh] Check no --profile options" {

    expected_output=${SCRIPT_TESTDIR}/latest/default.out

    assert_exist $expected_output

    run dl_dep.sh -n "${BATS_TEST_TMPDIR}"

    while IFS= read -r line
    do
        assert_output --partial "$line"
    done < "$expected_output"
}

@test "[dl_dep.sh] Check --profile option without argument" {
    run -1 dl_dep.sh -p
    assert_output --partial "ERROR: Missing argument for -p/--profile option"
}

@test "[dl_dep.sh] Check invalid --profile option without DESTINATION_PATH" {
    run -1 dl_dep.sh -p foobar
    assert_output --partial "ERROR: Positional arguments missing."
}

@test "[dl_dep.sh] Check valid --profile option without DESTINATION_PATH" {
    run dl_dep.sh -p default
    assert_output --partial "ERROR: Positional arguments missing."
}

@test "[dl_dep.sh] Check unknown --profile option" {

    profile_name=default
    profile_version=latest

    run -1 dl_dep.sh -n -p foobar "${BATS_TEST_TMPDIR}"

    assert_output "ERROR: 'foobar' not found in '$profile_name:$profile_version'"

}

@test "[dl_dep.sh] Check valid --profile option, no PROFILE_NAME or PROFILE_VERSION" {

    dependency_names=($(dl_dep.sh -l default:latest | perl -lne "print for /^\s{4}(\w+(?::\w+)*):.*$/"))

    for dep in "${dependency_names[@]}"; do
        destination_path=$(readlink -f ${BATS_TEST_TMPDIR})

        run dl_dep.sh -n -p "${dep}" "${BATS_TEST_TMPDIR}"

        assert_output --regexp \
"Destination path is set to  \"${destination_path}\"
Profile name: default
Profile version: latest
------------------------------------
Downloaded|Cloned '.*' to '${dep}'.*
Done"

    done
}

@test "[dl_dep.sh] Check valid --profile option, PROFILE_NAME only" {

    profile_names=($(dl_dep.sh -l latest | perl -lne "print for /^\* (\w+):.*$/"))

    for pn in "${profile_names[@]}"; do

        dependency_names=($(dl_dep.sh -l ${pn}:latest | perl -lne "print for /^\s{4}(\w+(?::\w+)*):.*$/"))

        for dep in "${dependency_names[@]}"; do
            destination_path=$(readlink -f ${BATS_TEST_TMPDIR})

            run dl_dep.sh -n -p "${dep}@${pn}" "${BATS_TEST_TMPDIR}"

            assert_output --regexp \
"Destination path is set to  \"${destination_path}\"
Profile name: ${pn}
Profile version: latest
------------------------------------
Downloaded|Cloned '.*' to '${dep}'.*
Done"

        done
    done
}

@test "[dl_dep.sh] Check valid --profile option, PROFILE_NAME and PROFILE_VERSION" {

    profile_versions=($(dl_dep.sh -l | perl -lne "print for /^\s{2}(.*?):$/"))

    for pv in "${profile_versions[@]}"; do
        profile_names=($(dl_dep.sh -l "${pv}" | perl -lne "print for /^\* (\w+):.*$/"))

        for pn in "${profile_names[@]}"; do

            dependency_names=($(dl_dep.sh -l ${pn}:${pv} | perl -lne "print for /^\s{4}(\w+(?::\w+)*):.*$/"))

            for dep in "${dependency_names[@]}"; do
                destination_path=$(readlink -f ${BATS_TEST_TMPDIR})

                run dl_dep.sh -n -p "${dep}@${pn}:${pv}" "${BATS_TEST_TMPDIR}"

                assert_output --regexp \
"Destination path is set to  \"${destination_path}\"
Profile name: ${pn}
Profile version: ${pv}
------------------------------------
Downloaded|Cloned '.*' to '${dep}'.*
Done"

            done
        done
    done
}
Loading