Trying to run both default and scenario tests on Travis

* Aborting rake tests if subshells fail plus attempting to make
gvm-installer less destructive for easing local verification of the
tests that run on Travis.
* Getting rubocop happy with the Rakefile, collapsing things a bit
This commit is contained in:
Dan Buch
2014-07-22 10:38:47 -04:00
parent ac17654314
commit 03d7843f69
3 changed files with 46 additions and 25 deletions
+7 -2
View File
@@ -1,7 +1,12 @@
language: c
os: [linux, osx]
osx_image: mavericks
env:
global:
- SRC_REPO=$TRAVIS_BUILD_DIR
- GVM_NO_GIT_BAK=1
- GVM_NO_UPDATE_PROFILE=1
before_install:
- "binscripts/gvm-installer $TRAVIS_COMMIT $TRAVIS_BUILD_DIR/tmp"
- binscripts/gvm-installer $TRAVIS_COMMIT $TRAVIS_BUILD_DIR/tmp
install: gem install tf -v '>=0.4.1'
script: source $TRAVIS_BUILD_DIR/tmp/gvm/scripts/gvm; tf --text tests/*.sh
script: source $TRAVIS_BUILD_DIR/tmp/gvm/scripts/gvm; rake default scenario
+28 -14
View File
@@ -1,27 +1,41 @@
require 'tmpdir'
def root_path
File.expand_path('../.', __FILE__)
end
def commit
@commit ||= (
ENV['TRAVIS_COMMIT'] || `git rev-parse --abbrev-ref HEAD`.chomp
)
end
task :default do
root_path = File.expand_path "../.", __FILE__
Dir.mktmpdir("gvm-test") do |tmpdir|
puts `binscripts/gvm-installer binary_default #{tmpdir}`
pid = fork do
exec("bash -c 'source #{tmpdir}/gvm/scripts/gvm; tf --text #{tmpdir}/gvm/tests/*.sh'")
end
Process.waitpid(pid)
Dir.mktmpdir('gvm-test') do |tmpdir|
system(<<-EOSH) || fail
bash -c '
set -e
#{root_path}/binscripts/gvm-installer #{commit} #{tmpdir}
source #{tmpdir}/gvm/scripts/gvm
tf --text #{tmpdir}/gvm/tests/*.sh
'
EOSH
end
end
task :scenario do
root_path = File.expand_path "../.", __FILE__
Dir["#{root_path}/tests/scenario/*_comment_test.sh"].each do |test|
name = File.basename(test)
puts "Running scenario #{name}..."
Dir.mktmpdir("gvm-test") do |tmpdir|
install = `binscripts/gvm-installer binary_default #{tmpdir}`
pid = fork do
exec("bash -c 'source #{tmpdir}/gvm/scripts/gvm; tf --text #{tmpdir}/gvm/tests/scenario/#{name}'")
end
Process.waitpid(pid)
Dir.mktmpdir('gvm-test') do |tmpdir|
system(<<-EOSH) || fail
bash -c '
set -e
#{root_path}/binscripts/gvm-installer #{commit} #{tmpdir}
source #{tmpdir}/gvm/scripts/gvm
tf --text #{tmpdir}/gvm/tests/scenario/#{name}
'
EOSH
end
end
end
+11 -9
View File
@@ -60,7 +60,7 @@ SRC_REPO=${SRC_REPO:-https://github.com/moovweb/gvm.git}
# Is gvm-installer being called from the origin repo?
# If so, skip the clone and source locally!
# This prevents, the CI to break on non-merge commits
# This prevents CI from breaking on non-merge commits.
GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
@@ -87,20 +87,22 @@ cd "$GVM_DEST/$GVM_NAME" && git checkout --quiet "$BRANCH" 2> /dev/null || displ
popd > /dev/null
mv "$GVM_DEST/$GVM_NAME/.git" "$GVM_DEST/$GVM_NAME/git.bak"
[ -z "$GVM_NO_GIT_BAK" ] && mv "$GVM_DEST/$GVM_NAME/.git" "$GVM_DEST/$GVM_NAME/git.bak"
source_line="[[ -s \"${GVM_DEST}/$GVM_NAME/scripts/gvm\" ]] && source \"${GVM_DEST}/$GVM_NAME/scripts/gvm\""
source_file="${GVM_DEST}/$GVM_NAME/scripts/gvm"
if [ -n "$ZSH_NAME" ]; then
update_profile "$HOME/.zshrc"
elif [ "$(uname)" == "Linux" ]; then
update_profile "$HOME/.bashrc" || update_profile "$HOME/.bash_profile"
elif [ "$(uname)" == "Darwin" ]; then
update_profile "$HOME/.profile" || update_profile "$HOME/.bash_profile"
if [ -z "$GVM_NO_UPDATE_PROFILE" ] ; then
if [ -n "$ZSH_NAME" ]; then
update_profile "$HOME/.zshrc"
elif [ "$(uname)" == "Linux" ]; then
update_profile "$HOME/.bashrc" || update_profile "$HOME/.bash_profile"
elif [ "$(uname)" == "Darwin" ]; then
update_profile "$HOME/.profile" || update_profile "$HOME/.bash_profile"
fi
fi
if [ "$?" != "0" ]; then
if [ -z "$GVM_NO_UPDATE_PROFILE" ] && [ "$?" != "0" ]; then
echo "Unable to locate profile settings file(Something like $HOME/.bashrc or $HOME/.bash_profile)"
echo
echo " You will have to manually add the following line:"