Skip to content
This repository has been archived by the owner on May 31, 2018. It is now read-only.

[WIP] Add tests and Travis CI config #784

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sudo: required
language: bash

services:
- docker

before_install: docker build -t arch-pacaur tests/image

env:
- TEST="make && sudo make install"
- TEST="tests/test_packages.sh"

script: docker run -v $(pwd):/home/pacaur/pacaur arch-pacaur /bin/bash -lc "sudo chown -R pacaur .; $TEST"
19 changes: 19 additions & 0 deletions tests/image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM base/devel
# update the image and install pacaur dependencies
RUN pacman -Syu --noconfirm
RUN pacman -S --noconfirm git expac

# prepare the pacaur environment
RUN useradd -m pacaur
RUN echo 'pacaur ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

# build cower
USER pacaur
WORKDIR /home/pacaur
RUN git clone https://aur.archlinux.org/cower.git
WORKDIR /home/pacaur/cower
RUN gpg --recv-keys --keyserver hkp://pgp.mit.edu 1EB2638FF56C0C53
RUN makepkg -sri --noconfirm

RUN mkdir -p /home/pacaur/pacaur
WORKDIR /home/pacaur/pacaur
35 changes: 35 additions & 0 deletions tests/test_packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

##
# Test command given as argument.
#
# $1 = command
##
test_command()
{
COMMAND="$1 &> /dev/null"
if eval $COMMAND;then
echo OK
else
echo FAILED
ANY_FAILED=true
fi
}

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
# Use this repository pacaur script by default
if [ -z ${PACAUR} ]; then PACAUR="${SCRIPTPATH::-5}pacaur"; fi
# Track any error
ANY_FAILED=false
# Packages to be processed
PACKAGES="shellcheck-static"

echo "Testing operation with packages:"
echo -n "Update system..."
test_command "${PACAUR} -Syu --noconfirm"
echo -n "Install packages..."
test_command "${PACAUR} -S --noconfirm --noedit ${PACKAGES}"
echo -n "Uninstall packages..."
test_command "${PACAUR} -R --noconfirm ${PACKAGES}"

if ${ANY_FAILED}; then exit 1; else exit 0; fi