[test][chore] add travis config and use git2 dependency in test

cc @bomgar
This commit is contained in:
Maximilien Riehl 2018-03-26 08:47:01 +02:00
parent b54783917c
commit 2b8bab380b
No known key found for this signature in database
GPG Key ID: 9B0645EDB075625E
2 changed files with 34 additions and 0 deletions

15
.travis.yml Normal file
View File

@ -0,0 +1,15 @@
language: rust
services:
- docker
os:
- linux
script:
- bash ./test-image
notifications:
email:
on_success: never
on_failure: always

View File

@ -19,7 +19,26 @@ set -euo pipefail
export USER=rust
cargo new --vcs none --bin testme
cd testme
# depending on git2 (and using it) makes the test much better, because git2 links against openssl and libz-sys among others
sed -i 's/\[dependencies\]/\[dependencies\]\ngit2 = \"0.6\"/' Cargo.toml
echo '
extern crate git2;
use git2::Repository;
fn main() {
let _local = Repository::init(\"fkbr\");
println!(\"Hello, world!\");
}' > src/main.rs
cargo build
# ldd will not die if the file does not exist, we need to check that too
if [ ! -f target/x86_64-unknown-linux-musl/debug/testme ]; then
echo 'binary was not created by cargo build or has unexpected name. Heres whats in target:' 1>&2
# no tree in image, but this also works
set -x
ls -l target && ls -l target/x86_64-unknown-linux-musl && ls -l target/x86_64-unknown-linux-musl/debug
exit 1
fi
echo 'Checking to make sure it is not a dynamic executable'
if ldd target/x86_64-unknown-linux-musl/debug/testme; then
echo 'Executable is not static!' 1>&2