Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add installation tests for all packages #12

Merged
merged 2 commits into from
Feb 15, 2017
Merged
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
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Ignore files generated by nested Zulu install
tests/_support/.config/*
tests/_support/.zulu/*
tests/_support/zulu-install.zsh

# Ignore output
tests/_output/*
!tests/_output/.gitkeep

# Ignore generated package test files
tests/packages/*
22 changes: 15 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
branches:
only:
- master
sudo: required
before_script:
- sudo apt-get install zsh
addons:
apt:
packages:
zsh
dist: trusty
install:
- mkdir .bin
- curl -L https://raw.githubusercontent.com/molovo/revolver/master/revolver > .bin/revolver
- curl -L https://raw.githubusercontent.com/molovo/color/master/color.zsh > .bin/color
- curl -L https://raw.githubusercontent.com/molovo/zunit/master/zunit > .bin/zunit
- chmod u+x .bin/{color,revolver,zunit}
- export PATH="$PWD/.bin:$PATH"
script: zunit
after_success:
- git config --global user.email "hi@molovo.co"
- git config --global user.name "James Dinsdale"
- git remote rm origin
- git remote add origin https://molovo:${GH_TOKEN}@github.com/zulu-zsh/index.git
script: make publish
- if [[ "$TRAVIS_BRANCH" = "master" && "$TRAVIS_PULL_REQUEST" = "false" ]]; then make publish; fi
env:
global:
secure: mVESbce+VicO31dTfjUJE/Fhc/CJoecaTcreum3vCeHNYZPe2QegOetzj+B1MpCLOnTSeRxq5XTMw1V/orlPfWs/X7brkCsW/tsBn+DagkGJ66/0RV1lXSlHafku6gS+WEVWYSUkv69v3v4aLWAigp/fWSbha8u9go+eYxah5rbo5dCY2cNEt5062IXowUBUdmr3JrOKHVrOQG8d3dDEBk/iVIe/3aDewjSN+7p73ps2qWr2OzuKNenf9AT8CRI1dkaxfLghqpB6XdQtscAmdPL4Ba9EnvYq1iibb+upiCp2DFCqdaQx2StiZcGgXT/Un6fm5g2317lCd6S17IbNij4/SoSwfx8V66jrDJDvARo5KcikH1FL+oEVi90KMap19fDXVWbJN3jpxC3QT+LvQUYr/g27Rt+0FvUU7pWOUFEPkY0+2d3SIsH2up+suBaCPDD6hJ9bN27eo0OpKe0C/JOMveCHLmWW3DwdJpSw7+/9tmAUAbJK9Ss/8Wedwpxfh2/utQPuJZQc84q9Dj5BIlGf32MCxp+0psSfbtkcJauvZ6pHW/eWPvFqMUPoWvTDWf/ivAks8AheayG8lum1k+htLNEpEsRRejpDQ6JkWyKKX1thnk+wd6PJs9HwIDkUJPcs9lqKdjbRZ2s+KEPzJRlm7OIU0M9vbZ0OpzN/OJA=
6 changes: 6 additions & 0 deletions .zunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
tap: false
directories:
tests: tests
output: tests/_output
support: tests/_support
time_limit: 30
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
build:
zsh ./build.zsh

test:
zunit

publish:
git fetch origin
git checkout gh-pages
Expand Down
Empty file added tests/_output/.gitkeep
Empty file.
Empty file added tests/_support/.gitkeep
Empty file.
64 changes: 64 additions & 0 deletions tests/_support/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env zsh

# Set Zulu directories
export ZULU_DIR="$PWD/tests/_support/.zulu"
export ZULU_CONFIG_DIR="$PWD/tests/_support/.config/zulu"
export ZULU_INSTALL_SCRIPT="$PWD/tests/_support/zulu-install.zsh"

# Check if Zulu is already installed in the support directory
if [[ ! -d "$ZULU_DIR" ]]; then
# Check if the Zulu install script has already been downloaded
if [[ ! -f "$ZULU_INSTALL_SCRIPT" ]]; then
curl -L https://zulu.sh/install > $ZULU_INSTALL_SCRIPT
fi

# Source the Zulu install script
source "$PWD/tests/_support/zulu-install.zsh"
fi

# If the index directory is still present, remove it and
# create a symlink to the current directory so that Zulu
# uses the index we are testing
if [[ ! -L "$ZULU_DIR/index" ]]; then
if [[ -d "$ZULU_DIR/index" ]]; then
rm -rf "$ZULU_DIR/index"
fi

ln -s "$PWD" "$ZULU_DIR/index"
fi

# Create a list of the files in the packages directory
oldIFS=$IFS
IFS=$'\n'
local -a packages; packages=($(ls "$PWD/packages"))
IFS=$oldIFS

# Create the directory for generated tests if it does not exist
if [[ ! -d "$PWD/tests/packages" ]]; then
mkdir -p "$PWD/tests/packages"
fi

# Generate test files for packages if they don't already exist
for package in ${packages[@]}; do
if [[ ! -f "$PWD/tests/packages/$package.zunit" ]]; then
echo "#!/usr/bin/env zunit

@test 'Test $package installation' {
run zulu install --no-autoselect-themes --ignore-dependencies $package

assert \$state equals 0
assert \"\$PWD/tests/_support/.zulu/packages/$package\" is_dir
}

@test 'Test $package uninstallation' {
run zulu uninstall $package

assert \$state equals 0
}" > "$PWD/tests/packages/$package.zunit"
echo "Generated new test file for $package"
fi
done

# Source the embedded Zulu installation
source "$ZULU_DIR/core/zulu"
zulu init