mirror of
https://github.com/icewind1991/notify-redis.git
synced 2026-06-03 18:24:12 +02:00
add makefile tests and travis config
This commit is contained in:
parent
5d74cb1485
commit
c0337e55d9
6 changed files with 90 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,3 +1,3 @@
|
||||||
|
/test
|
||||||
/target
|
/target
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
|
|
||||||
9
.travis.yml
Normal file
9
.travis.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
sudo: required
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
- redis-server
|
||||||
|
install:
|
||||||
|
- docker pull ekidd/rust-musl-builder:latest
|
||||||
|
script:
|
||||||
|
- "./travis-build.sh notify-redis ${TRAVIS_OS_NAME}"
|
||||||
|
- "./test.sh ./notify-redis-${TRAVIS_OS_NAME}"
|
||||||
8
Dockerfile
Normal file
8
Dockerfile
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
FROM ekidd/rust-musl-builder
|
||||||
|
|
||||||
|
# We need to add the source code to the image because `rust-musl-builder`
|
||||||
|
# assumes a UID of 1000, but TravisCI has switched to 2000.
|
||||||
|
ADD . ./
|
||||||
|
RUN sudo chown -R rust:rust .
|
||||||
|
|
||||||
|
CMD cargo build --release
|
||||||
9
Makefile
Normal file
9
Makefile
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
all: target/x86_64-unknown-linux-musl/release/notify-redis
|
||||||
|
|
||||||
|
target/x86_64-unknown-linux-musl/release/notify-redis: Cargo.toml src/main.rs
|
||||||
|
docker run --rm -it -v "$(CURDIR):/home/rust/src" ekidd/rust-musl-builder cargo build --release
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
|
||||||
|
test: target/x86_64-unknown-linux-musl/release/notify-redis
|
||||||
|
./test.sh
|
||||||
56
test.sh
Executable file
56
test.sh
Executable file
|
|
@ -0,0 +1,56 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function assert_notify {
|
||||||
|
actual="$(redis-cli rpop notify)"
|
||||||
|
if [ "$actual" != "$1" ]
|
||||||
|
then
|
||||||
|
echo "'$actual' not equal to expected '$1'"
|
||||||
|
killall $(basename $bin)
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdir -p test
|
||||||
|
rm test/*
|
||||||
|
redis-cli del notify
|
||||||
|
|
||||||
|
bin=$1;
|
||||||
|
: ${bin:="target/x86_64-unknown-linux-musl/release/notify-redis"}
|
||||||
|
|
||||||
|
echo "running tests with $bin"
|
||||||
|
|
||||||
|
$bin "$PWD/test" redis://localhost notify &
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
echo foo > test/foo.txt
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
assert_notify "write|$(pwd)/test/foo.txt"
|
||||||
|
assert_notify ''
|
||||||
|
|
||||||
|
mv test/foo.txt test/bar.txt
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
assert_notify "rename|$(pwd)/test/foo.txt|$(pwd)/test/bar.txt"
|
||||||
|
assert_notify ""
|
||||||
|
|
||||||
|
rm test/bar.txt
|
||||||
|
echo asd > test/bar.txt
|
||||||
|
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
assert_notify "write|$(pwd)/test/bar.txt"
|
||||||
|
assert_notify ""
|
||||||
|
|
||||||
|
rm test/bar.txt
|
||||||
|
sleep 2
|
||||||
|
echo asd > test/bar.txt
|
||||||
|
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
assert_notify "remove|$(pwd)/test/bar.txt"
|
||||||
|
assert_notify "write|$(pwd)/test/bar.txt"
|
||||||
|
assert_notify ""
|
||||||
|
|
||||||
|
killall $(basename $bin)
|
||||||
7
travis-build.sh
Executable file
7
travis-build.sh
Executable file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
echo "Building static binaries using ekidd/rust-musl-builder"
|
||||||
|
docker build -t build-"$1"-image .
|
||||||
|
docker run -it --name build-"$1" build-"$1"-image
|
||||||
|
docker cp build-"$1":/home/rust/src/target/x86_64-unknown-linux-musl/release/"$1" "$1-$2"
|
||||||
|
docker rm build-"$1"
|
||||||
|
docker rmi build-"$1"-image
|
||||||
Loading…
Add table
Add a link
Reference in a new issue