#4 tests: add bundler unit tests
Opened 5 years ago by mvadkert. Modified 5 years ago
rpms/ mvadkert/rubygem-bundler master  into  rawhide

@@ -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 <mvadkert@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   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

file added
+30
@@ -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

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 mvadkert@redhat.com

Note that currently the tests fail with:

Finished in 13 minutes 29 seconds (files took 0.70191 seconds to load)
2079 examples, 6 failures, 8 pending

This will need investigation from the package maintainers.

The logs which you should see when you run the tests are here:

https://paste.fedoraproject.org/paste/P-dMO-5WZsAp5HDj9IOnmg

Note that there are some tests, that fail on gcc not found, but the machine has gcc installed:

Example:

[root@efa5491fa605 bundler-unit-tests]# which gcc
/usr/bin/gcc

But the test log shows:

$ /usr/bin/ruby -I/tmp/tmp.wENAp3wVg3/BUILD/rubygem-bundler-1.13.7/usr/share/gems/gems/bundler-1.13.7/lib:/tmp/tmp.wENAp3wVg3/BUILD/rubygem-bundler-1.13.7/usr/share/gems/gems/bundler-1.13.7/spec -rsupport/hax /tmp/tmp.wENAp3wVg3/BUILD/rubygem-bundler-1.13.7/usr/share/gems/gems/bundler-1.13.7/exe/bundle install --path vendor/bundle --no-color
Fetching /tmp/tmp.wENAp3wVg3/BUILD/rubygem-bundler-1.13.7/usr/share/gems/gems/bundler-1.13.7/tmp/libs/very_simple_git_binary-1.0
Fetching source index from file:/tmp/tmp.wENAp3wVg3/BUILD/rubygem-bundler-1.13.7/usr/share/gems/gems/bundler-1.13.7/tmp/gems/remote1/
Resolving dependencies...
Using very_simple_git_binary 1.0 from /tmp/tmp.wENAp3wVg3/BUILD/rubygem-bundler-1.13.7/usr/share/gems/gems/bundler-1.13.7/tmp/libs/very_simple_git_binary-1.0 (at 49a0b5c@49a0b5c)
Using bundler 1.13.7
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /tmp/tmp.wENAp3wVg3/BUILD/rubygem-bundler-1.13.7/usr/share/gems/gems/bundler-1.13.7/tmp/bundled_app/vendor/bundle/ruby/2.4.0/bundler/gems/very_simple_git_binary-1.0-49a0b5cfa293/ext
/usr/bin/ruby -r ./siteconf20180607-9036-bwe68i.rb extconf.rb
creating Makefile

current directory: /tmp/tmp.wENAp3wVg3/BUILD/rubygem-bundler-1.13.7/usr/share/gems/gems/bundler-1.13.7/tmp/bundled_app/vendor/bundle/ruby/2.4.0/bundler/gems/very_simple_git_binary-1.0-49a0b5cfa293/ext
make "DESTDIR=" clean
rm -f
rm -f very_simple_binary_c.so  *.o  *.bak mkmf.log .*.time

current directory: /tmp/tmp.wENAp3wVg3/BUILD/rubygem-bundler-1.13.7/usr/share/gems/gems/bundler-1.13.7/tmp/bundled_app/vendor/bundle/ruby/2.4.0/bundler/gems/very_simple_git_binary-1.0-49a0b5cfa293/ext
make "DESTDIR="
gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I.   -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -mtune=generic -fPIC -m64 -o very_simple_binary.o -c very_simple_binary.c
make: gcc: Command not found
make: *** [Makefile:243: very_simple_binary.o] Error 127

make failed, exit code 2

Gem files will remain installed in /tmp/tmp.wENAp3wVg3/BUILD/rubygem-bundler-1.13.7/usr/share/gems/gems/bundler-1.13.7/tmp/bundled_app/vendor/bundle/ruby/2.4.0/bundler/gems/very_simple_git_binary-1.0-49a0b5cfa293 for inspection.
Results logged to /tmp/tmp.wENAp3wVg3/BUILD/rubygem-bundler-1.13.7/usr/share/gems/gems/bundler-1.13.7/tmp/bundled_app/vendor/bundle/ruby/2.4.0/bundler/gems/extensions/x86_64-linux/2.4.0/very_simple_git_binary-1.0-49a0b5cfa293/gem_make.out

An error occurred while installing very_simple_git_binary (1.0), and Bundler cannot continue.
# $? => 5
  doesn't remove extensions artifacts from bundled git gems after clean (FAILED - 2)

@vondruch maybe there is a problem with $PATH during running of tests. I have no other idea :(

@vondruch hi hi, any luck looking @ this pls?