Skip to content

Commit

Permalink
Test book in CI, with smarts for cleaning libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
azriel91 committed Sep 12, 2019
1 parent a0f6ee8 commit 0742ad7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,14 @@ pipeline {
}
steps {
echo 'Beginning tests...'

// Clean amethyst build artifacts so `mdbook test` does not fail on multiple
// built libraries found.
sh './scripts/book_library_clean.sh'

sh 'cargo test --all --features "vulkan sdl_controller json saveload"'
sh 'mdbook test -L ./target/debug/deps book'

echo 'Tests done!'
}
}
Expand Down
28 changes: 28 additions & 0 deletions scripts/book_library_clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# /bin/sh
#
# Clean amethyst build artifacts so `mdbook test` does not fail on multiple
# built libraries found.
#
# Allow nullglob so build doesn't fail if there were no build artifacts.

set -e

shopt -u | grep -q nullglob && changed=true && shopt -s nullglob

crates_to_clean=$(
find book -type f -name '*.md' -exec grep -hF 'extern crate ' {} \+ |
grep -o '[a-z0-9_]\+;$' |
cut -d ';' -f 1 |
sort |
uniq
)

for crate in $crates_to_clean
do
echo Running rm -rf "target/debug/deps/lib${crate}-*" "target/debug/deps/${crate}-*"
rm -rf "target/debug/deps/lib${crate}-*" "target/debug/deps/${crate}-*"
done

[ $changed ] && shopt -u nullglob; unset changed

exit 0

0 comments on commit 0742ad7

Please sign in to comment.