Commit 4b2eade5 authored by Julius Athenstaedt's avatar Julius Athenstaedt Committed by sevenuz
Browse files

fix tests for unified profile flag in dependencyscripts

parent ff7ef428
Loading
Loading
Loading
Loading
+3 −13
Original line number Diff line number Diff line
@@ -50,8 +50,7 @@ declare -A PROFILE_CLONEDEPS_ARGS PROFILE_CLONEDEPS_PATCHES
usage_short() {
	echo "
usage: compile_dep.sh -h |
                      -p PROFILE_NAME[:PROFILE_VERSION] |
                      -d DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] |
                      -p DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] |
                      -l [PROFILE_NAME:[PROFILE_VERSION]] |
                      -h
                      [ -P PROFILES_DIR ] [ -j COMPILE_CORES] [ -n ]
@@ -74,16 +73,7 @@ optional arguments:
    -h, --help  Shows this help message and exits
    -l, --list-dependencies [[PROFILE_NAME:]PROFILE_VERSION]
                List dependencies available for building and installation
    -p, --profile PROFILE_NAME[:PROFILE_VERSION]
                Allows installing a pre-defined set of dependencies as defined
                in \${PROFILES_DIR}/PROFILE_NAME.specs. This is useful to
                deploy specific library versions and/or configurations,
                using a recognizable name. Optionally, PROFILE_NAME may include
                a specific version for the profile, e.g. 'mogon2:latest' or
                'ngio:0.9.3', which will download the dependencies defined for
                that specific version. If unspecified, the 'default:latest' profile
                will be used, which should include all the possible dependencies.
    -d, --dependency DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]]
    -p, --profile DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]]
                Build and install a specific dependency, ignoring any --profile
                option provided. If PROFILE_NAME is unspecified, the 'default'
                profile will be used. Similarly, if PROFILE_VERSION is
@@ -376,7 +366,7 @@ while [[ $# -gt 0 ]]; do
        [ -n "${EXECUTION_MODE}" ] && exec_mode_error || EXECUTION_MODE='dependency'

        if [[ -z "$2" ]]; then
            echo "ERROR: Missing argument for -d/--dependency option"
            echo "ERROR: Missing argument for -p/--profile option"
            exit
        fi

+3 −13
Original line number Diff line number Diff line
@@ -307,8 +307,7 @@ wgetdeps() {

usage_short() {
    echo "
usage: dl_dep.sh -p PROFILE_NAME[:PROFILE_VERSION] |
                 -d DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] |
usage: dl_dep.sh -p DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] |
                 -l [[PROFILE_NAME:]PROFILE_VERSION] |
                 -h
                 [ -P PROFILES_DIR ] [ -n ]
@@ -330,16 +329,7 @@ optional arguments:
        -h, --help              Shows this help message and exits
        -l, --list-dependencies [[PROFILE_NAME:]PROFILE_VERSION]
                                List dependency configuration profiles available for download
        -p, --profile PROFILE_NAME[:PROFILE_VERSION]
                                Allows downloading a pre-defined set of dependencies as defined
                                in \${PROFILES_DIR}/PROFILE_NAME.specs. This is useful to
                                deploy specific library versions and/or configurations,
                                using a recognizable name. Optionally, PROFILE_NAME may include
                                a specific version for the profile, e.g. 'mogon2:latest' or
                                'ngio:0.9.3', which will download the dependencies defined for
                                that specific version. If unspecified, the 'default:latest' profile
                                will be used, which should include all the possible dependencies.
        -d, --dependency DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]]
        -p, --profile DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]]
                                Build and install a specific dependency, ignoring any --profile
                                option provided. If PROFILE_NAME is unspecified, the 'default'
                                profile will be used. Similarly, if PROFILE_VERSION is unspecified,
@@ -371,7 +361,7 @@ while [[ $# -gt 0 ]]; do
        [ -n "${EXECUTION_MODE}" ] && exec_mode_error || EXECUTION_MODE='dependency'

        if [[ -z "$2" ]]; then
            echo "ERROR: Missing argument for -d/--dependency option"
            echo "ERROR: Missing argument for -p/--profile option"
            exit 1
        fi

+11 −70
Original line number Diff line number Diff line
@@ -43,16 +43,6 @@ teardown() {
    done < "$expected_output"
}

@test "[compile_dep.sh] Check --profile and --dependency option at the same time" {
    run -1 compile_dep.sh -p foobar -d barbaz
    assert_output --partial "ERROR: --profile and --dependency options are mutually exclusive" 
}

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

@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."
@@ -63,67 +53,18 @@ teardown() {
    assert_output --partial "ERROR: Positional arguments missing."
}

@test "[compile_dep.sh] Check invalid --profile option" {
    run -1 compile_dep.sh -p foo bar baz
    assert_output --partial "Profile 'foo:latest' does not exist." 
}

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

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

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

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

        assert_exist $expected_output

        run compile_dep.sh -n -p "${pn}" foo bar

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

}

@test "[compile_dep.sh] Check valid --profile option, with 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 ${pv} | perl -lne "print for /^\* (\w+):.*$/"))

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

            expected_output=${SCRIPT_TESTDIR}/${pv}/${pn}.out

            assert_exist $expected_output

            run compile_dep.sh -n -p "${pn}:${pv}" foo bar

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

    done
}

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

    profile_name=default
    profile_version=latest

    run -1 compile_dep.sh -n -d foobar bar baz
    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 --dependency option, no PROFILE_NAME or 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+)*):.*$/"))

@@ -131,7 +72,7 @@ teardown() {
        source_path=$(readlink -f ${BATS_TEST_TMPDIR}/foo)
        install_path=$(readlink -f ${BATS_TEST_TMPDIR}/bar)

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

        assert_output --regexp \
"CORES = [0-9]+ \(default\)
@@ -149,7 +90,7 @@ Done"
    done
}

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

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

@@ -161,7 +102,7 @@ Done"
            source_path=$(readlink -f ${BATS_TEST_TMPDIR}/foo)
            install_path=$(readlink -f ${BATS_TEST_TMPDIR}/bar)

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

            assert_output --regexp \
"CORES = [0-9]+ \(default\)
@@ -180,7 +121,7 @@ Done"
    done
}

@test "[compile_dep.sh] Check valid --dependency option, PROFILE_NAME and PROFILE_VERSION" {
@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}(.*?):$/"))

@@ -196,7 +137,7 @@ Done"
                source_path=$(readlink -f ${BATS_TEST_TMPDIR}/foo)
                install_path=$(readlink -f ${BATS_TEST_TMPDIR}/bar)

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

                assert_output --regexp \
"CORES = [0-9]+ \(default\)
+12 −70
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ teardown() {
    assert_output --partial "usage: dl_dep.sh"
}

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

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

@@ -43,11 +43,6 @@ teardown() {
    done < "$expected_output"
}

@test "[dl_dep.sh] Check --profile and --dependency option at the same time" {
    run -1 dl_dep.sh -p foobar -d barbaz
    assert_output --partial "ERROR: --profile and --dependency options are mutually exclusive" 
}

@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"
@@ -63,78 +58,25 @@ teardown() {
    assert_output --partial "ERROR: Positional arguments missing."
}

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

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

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

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

        assert_exist $expected_output

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

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

@test "[dl_dep.sh] Check valid --profile option, with 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

            expected_output=${SCRIPT_TESTDIR}/${pv}/${pn}.out

            assert_exist $expected_output

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

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

    done
}

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

    profile_name=default
    profile_version=latest

    run -1 dl_dep.sh -n -d foobar "${BATS_TEST_TMPDIR}"
    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 invalid --dependency option without DESTINATION_PATH" {
    run -1 dl_dep.sh -d foobar
    assert_output --partial "ERROR: Positional arguments missing." 
}

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

@test "[dl_dep.sh] Check valid --dependency option, no PROFILE_NAME or 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 -d "${dep}" "${BATS_TEST_TMPDIR}"
        run dl_dep.sh -n -p "${dep}" "${BATS_TEST_TMPDIR}"

        assert_output --regexp \
"Destination path is set to  \"${destination_path}\"
@@ -147,7 +89,7 @@ Done"
    done
}

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

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

@@ -158,7 +100,7 @@ Done"
        for dep in "${dependency_names[@]}"; do
            destination_path=$(readlink -f ${BATS_TEST_TMPDIR})

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

            assert_output --regexp \
"Destination path is set to  \"${destination_path}\"
@@ -172,7 +114,7 @@ Done"
    done
}

@test "[dl_dep.sh] Check valid --dependency option, PROFILE_NAME and PROFILE_VERSION" {
@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}(.*?):$/"))

@@ -186,7 +128,7 @@ Done"
            for dep in "${dependency_names[@]}"; do
                destination_path=$(readlink -f ${BATS_TEST_TMPDIR})

                run dl_dep.sh -n -d "${dep}@${pn}:${pv}" "${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}\"