From 5bae896e5a11b0cdab4938f166187fa3d644f158 Mon Sep 17 00:00:00 2001 From: Miroslav Vadkerti Date: Jun 07 2018 12:31:03 +0000 Subject: tests: add bundler unit tests This patch adds test which executes bundler unit tests from the source rpm. For more inforamtion how to run the tests see: https://fedoraproject.org/wiki/CI/Quick_Start_Guide Signed-off-by: Miroslav Vadkerti --- diff --git a/tests/bundler-unit-tests/runtest.sh b/tests/bundler-unit-tests/runtest.sh new file mode 100644 index 0000000..5945084 --- /dev/null +++ b/tests/bundler-unit-tests/runtest.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Description: Runs upstream test suite +# Author: Miroslav Vadkerti +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2018 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || { echo "error: Beakerlib is not installed"; exit 1; } + +PACKAGE=rubygem-bundler +REQUIRES="rubygem-rspec ruby-devel rubygems-devel gcc" +VERSION=$(rpm -q --qf "%{VERSION}\n" $PACKAGE | tail -1) +RUNUSER="rubyuser" + +RunAsUser() { + rlRun "su $RUNUSER -c \"$1\"" $2 "$3" +} + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlRun "useradd rubyuser" 0 "Adding user rubyuser to the system" + rlRun "chown -R rubyuser:rubyuser $TmpDir" 0 + rlRun "rlFetchSrcForInstalled $PACKAGE" 0 "Fetching source package for bundler" + RunAsUser "rpm --define '_topdir $TmpDir' -i $TmpDir/*src.rpm" 0 "Installing the source rpm" + RunAsUser "rpmbuild --nodeps --define '_topdir $TmpDir' -bc $TmpDir/SPECS/*spec" 0 "Configuring build" + rlPhaseEnd + + rlPhaseStartTest "Run unit tests" + rlRun "cd $TmpDir/BUILD/$PACKAGE-$VERSION/usr/share/gems/gems/bundler-$VERSION" + RunAsUser "tar xzvf $TmpDir/SOURCES/*-specs.tgz" 0 "Unpacking specs into install directory" + RunAsUser "git init ." 0 "Tests require the folder to be a git repo" + RunAsUser "rake spec:deps" 0 "Installing deps" + RunAsUser "rspec spec | tee output.log" 0 "Run unit tests" + rlAssertGrep "examples, 0 failures," output.log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "userdel -r $RUNUSER" 0 "Removing rubyuser from the system" + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..2960c9f --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,30 @@ +--- +# +# Tests to run in a classic and container environment +# +- hosts: localhost + roles: + - role: standard-test-beakerlib + + tags: + - classic + - container + + tests: + - bundler-unit-tests + + required_packages: + - gcc + - rubygem-bundler + - rubygem-rspec + - ruby-devel + - rubygems-devel + - rpm-build + +# +# Tests for atomic host +# +- hosts: localhost + tags: + - atomic + # no compatible tests