diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d9a8dbd --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Jaroslav Prokop + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/plans/cucumber_install.fmf b/plans/cucumber_install.fmf new file mode 100644 index 0000000..c1627f9 --- /dev/null +++ b/plans/cucumber_install.fmf @@ -0,0 +1,5 @@ +summary: Basic smoke test +discover: + how: fmf +execute: + how: tmt diff --git a/tests/basic_test_suites/cucumber_with_aruba/features/support/env.rb b/tests/basic_test_suites/cucumber_with_aruba/features/support/env.rb new file mode 100644 index 0000000..fb0a661 --- /dev/null +++ b/tests/basic_test_suites/cucumber_with_aruba/features/support/env.rb @@ -0,0 +1 @@ +require 'aruba/cucumber' diff --git a/tests/basic_test_suites/cucumber_with_aruba/features/test.feature b/tests/basic_test_suites/cucumber_with_aruba/features/test.feature new file mode 100644 index 0000000..a162fa8 --- /dev/null +++ b/tests/basic_test_suites/cucumber_with_aruba/features/test.feature @@ -0,0 +1,31 @@ +Feature: Simple tests to showcase that Aruba works + + Background: + Given a file named "hello-world" with: + """ + Ahoy! + """ + + Scenario: Functioning executable + Given an executable named "bin/example-cli" with: + """ + #!/usr/bin/bash + echo "Hi!" + """ + When I successfully run `bin/example-cli` + Then the output should contain: + """ + Hi! + """ + + Scenario: Using background step definition + Given an executable named "bin/example-cli-2" with: + """ + #!/usr/bin/bash + cat "./hello-world" + """ + When I successfully run `bin/example-cli-2` + Then the output should contain: + """ + Ahoy! + """ diff --git a/tests/basic_test_suites/cucumber_with_aruba/main.fmf b/tests/basic_test_suites/cucumber_with_aruba/main.fmf new file mode 100644 index 0000000..b6ad9d7 --- /dev/null +++ b/tests/basic_test_suites/cucumber_with_aruba/main.fmf @@ -0,0 +1,6 @@ +summary: Test an example cucumber test suite with Aruba +test: ./test.sh + +require+: + - rubygem-cucumber + - rubygem-aruba diff --git a/tests/basic_test_suites/cucumber_with_aruba/test.sh b/tests/basic_test_suites/cucumber_with_aruba/test.sh new file mode 100755 index 0000000..c8ac7de --- /dev/null +++ b/tests/basic_test_suites/cucumber_with_aruba/test.sh @@ -0,0 +1,24 @@ +#!/bin/sh -eux + +PACKAGE=${PACKAGE:-} + +[ -n "$PACKAGE" ] || { + echo "env variable \$PACKAGE not specified, specify what package are we testing." >&2 + + exit 1 +} + +tmp=$(mktemp -d) +cp -r features "$tmp" + +pushd "$tmp" +cucumber > test_out.txt + +# Provide a way for this test to fail. If something +# is undefined, the exit code of `cucumber` is 0, +# which will not fail the execution of this file. +grep -q "2 scenarios (2 passed)" test_out.txt +grep -q "8 steps (8 passed)" test_out.txt +popd + +rm -rf "$tmp" diff --git a/tests/basic_test_suites/simple_cucumber_use/main.fmf b/tests/basic_test_suites/simple_cucumber_use/main.fmf new file mode 100644 index 0000000..1b72e32 --- /dev/null +++ b/tests/basic_test_suites/simple_cucumber_use/main.fmf @@ -0,0 +1,9 @@ +summary: Run basic cucumber test suite to test compatibility. +test: ./test.sh + +require+: + - git + - rubygem-jekyll + - rubygem-jekyll-email-protect + - rubygem-cucumber + - rubygem-rspec diff --git a/tests/basic_test_suites/simple_cucumber_use/test.sh b/tests/basic_test_suites/simple_cucumber_use/test.sh new file mode 100755 index 0000000..d9a4a33 --- /dev/null +++ b/tests/basic_test_suites/simple_cucumber_use/test.sh @@ -0,0 +1,22 @@ +#!/bin/sh -eux + +PACKAGE=${PACKAGE:-} + +[ -n "$PACKAGE" ] || { + echo "env variable \$PACKAGE not specified, specify what package are we testing." + + exit 1 +} + +echo $(rpm -qa "$PACKAGE") + +tmp=$(mktemp -d) +pushd "$tmp" + +git clone "https://gitlab.com/jackorp/jekyll-git-authors.git" +pushd jekyll-git-authors +cucumber . +popd + +popd +rm -rf "$tmp" diff --git a/tests/reverse_dependencies_build/main.fmf b/tests/reverse_dependencies_build/main.fmf new file mode 100644 index 0000000..2a74cf7 --- /dev/null +++ b/tests/reverse_dependencies_build/main.fmf @@ -0,0 +1,7 @@ +summary: Reverse rebuild a dependency with scratch build artifact +test: ./test.sh + +require+: + - mock + - python3-koji + - fedpkg diff --git a/tests/reverse_dependencies_build/rubygem-aruba.fmf b/tests/reverse_dependencies_build/rubygem-aruba.fmf new file mode 100644 index 0000000..a2f363c --- /dev/null +++ b/tests/reverse_dependencies_build/rubygem-aruba.fmf @@ -0,0 +1,2 @@ +environment: + BUILD_PACKAGE: rubygem-aruba diff --git a/tests/reverse_dependencies_build/rubygem-cucumber-wire.fmf b/tests/reverse_dependencies_build/rubygem-cucumber-wire.fmf new file mode 100644 index 0000000..d5c7fa4 --- /dev/null +++ b/tests/reverse_dependencies_build/rubygem-cucumber-wire.fmf @@ -0,0 +1,2 @@ +environment: + BUILD_PACKAGE: rubygem-cucumber-wire diff --git a/tests/reverse_dependencies_build/rubygem-cucumber.fmf b/tests/reverse_dependencies_build/rubygem-cucumber.fmf new file mode 100644 index 0000000..8c73ca9 --- /dev/null +++ b/tests/reverse_dependencies_build/rubygem-cucumber.fmf @@ -0,0 +1,2 @@ +environment: + BUILD_PACKAGE: rubygem-cucumber diff --git a/tests/reverse_dependencies_build/rubygem-nifti.fmf b/tests/reverse_dependencies_build/rubygem-nifti.fmf new file mode 100644 index 0000000..5db47e1 --- /dev/null +++ b/tests/reverse_dependencies_build/rubygem-nifti.fmf @@ -0,0 +1,2 @@ +environment: + BUILD_PACKAGE: rubygem-nifti diff --git a/tests/reverse_dependencies_build/rubygem-rspec-expectations.fmf b/tests/reverse_dependencies_build/rubygem-rspec-expectations.fmf new file mode 100644 index 0000000..9f8500c --- /dev/null +++ b/tests/reverse_dependencies_build/rubygem-rspec-expectations.fmf @@ -0,0 +1,2 @@ +environment: + BUILD_PACKAGE: rubygem-rspec-expectations diff --git a/tests/reverse_dependencies_build/rubygem-rspec-mocks.fmf b/tests/reverse_dependencies_build/rubygem-rspec-mocks.fmf new file mode 100644 index 0000000..6aff7bb --- /dev/null +++ b/tests/reverse_dependencies_build/rubygem-rspec-mocks.fmf @@ -0,0 +1,2 @@ +environment: + BUILD_PACKAGE: rubygem-rspec-mocks diff --git a/tests/reverse_dependencies_build/test.sh b/tests/reverse_dependencies_build/test.sh new file mode 100755 index 0000000..ec6eafc --- /dev/null +++ b/tests/reverse_dependencies_build/test.sh @@ -0,0 +1,42 @@ +#!/bin/sh -eux + +BUILD_PACKAGE=${BUILD_PACKAGE:-} +KOJI_TASK_ID=${KOJI_TASK_ID:-} + +[ -n "$BUILD_PACKAGE" ] || { + echo "env variable \$BUILD_PACKAGE not specified, specify what package are we testing." >&2 + + exit 1 +} + +[ -n "$KOJI_TASK_ID" ] || { + echo "env variable \$KOJI_TASK_ID not specified" >&2 + echo "This variable should be present in TestingFarm" >&2 + + exit 1 +} + +# Inspired by sut_install_commands.sh script available in TestingFarm run +( koji download-build --debuginfo --task-id --arch noarch --arch x86_64 --arch i686 $KOJI_TASK_ID || koji download-task --arch noarch --arch x86_64 --arch i686 $KOJI_TASK_ID ) | grep -E Downloading | cut -d " " -f 3 | tee "rpms-list-$KOJI_TASK_ID" +ls *[^.src].rpm | sed -r "s/(.*)-.*-.*/\1 \0/" | grep -Ev "i686" | awk "{print \$2}" | tee rpms-list + +# Prep mock with the packages here, otherwise we'd have to do a bit of +# gymnastics to set the paths correctly in rpms-list. +mock -r fedora-rawhide-x86_64 --verbose -i $(cat rpms-list) + +tmp=$(mktemp -d) +pushd $tmp + +fedpkg clone -a "rpms/$BUILD_PACKAGE" +# Previous clone will create a directory named after $BUILD_PACKAGE +# if it doesn't exist, it failed, so checking path exists seems pointless +pushd "$BUILD_PACKAGE" +srpm_path=$(fedpkg --release rawhide srpm | grep Wrote | cut -d':' -f2 | tr -d ' ') +# After fedpkg srpm we expect only a single package. +mock -r fedora-rawhide-x86_64 --verbose --no-clean "$srpm_path" +# No other checks on reverse built artifacts should be needed. +# install checks should be in other tests as it's not a focus of this one. +popd + +popd +rm -rf "$tmp" diff --git a/tests/reverse_dependencies_install/aruba_install/main.fmf b/tests/reverse_dependencies_install/aruba_install/main.fmf new file mode 100644 index 0000000..ca5cee2 --- /dev/null +++ b/tests/reverse_dependencies_install/aruba_install/main.fmf @@ -0,0 +1,2 @@ +summary: Verify functional installation of the rubygem-aruba package +test: ./test.sh diff --git a/tests/reverse_dependencies_install/aruba_install/test.sh b/tests/reverse_dependencies_install/aruba_install/test.sh new file mode 100755 index 0000000..08e3ce2 --- /dev/null +++ b/tests/reverse_dependencies_install/aruba_install/test.sh @@ -0,0 +1,23 @@ +#!/bin/sh -eux + +PACKAGE=${PACKAGE:-} + +[ -n "$PACKAGE" ] || { + echo "env variable \$PACKAGE not specified, specify what package are we testing." + + exit 1 +} + +present=$(rpm -qa $PACKAGE) + +# We assume dnf install privileges +dnf install -y rubygem-aruba + +after_install=$(rpm -qa $PACKAGE) + +[ "$present" = "$after_install" ] || { + echo "Mismatch of $PACKAGE NVR after installing cucumber." + echo "BEFORE --> $present" + echo "AFTER --> $after_install" + exit 1 +} diff --git a/tests/reverse_dependencies_install/cucumber_install/main.fmf b/tests/reverse_dependencies_install/cucumber_install/main.fmf new file mode 100644 index 0000000..f0191eb --- /dev/null +++ b/tests/reverse_dependencies_install/cucumber_install/main.fmf @@ -0,0 +1,2 @@ +summary: Verify functional installation of the main cucumber package +test: ./test.sh diff --git a/tests/reverse_dependencies_install/cucumber_install/test.sh b/tests/reverse_dependencies_install/cucumber_install/test.sh new file mode 100755 index 0000000..551eea4 --- /dev/null +++ b/tests/reverse_dependencies_install/cucumber_install/test.sh @@ -0,0 +1,27 @@ +#!/bin/sh -eux + +PACKAGE=${PACKAGE:-} + +[ -n "$PACKAGE" ] || { + echo "env variable \$PACKAGE not specified, specify what package are we testing." + + exit 1 +} + +present=$(rpm -qa $PACKAGE) + +# We assume dnf install privileges +dnf install -y rubygem-cucumber + +after_install=$(rpm -qa $PACKAGE) + +[ "$present" = "$after_install" ] || { + echo "Mismatch of $PACKAGE NVR after installing cucumber." + echo "BEFORE --> $present" + echo "AFTER --> $after_install" + exit 1 +} + +cucumber --help + +cucumber --version