From b7a62b8c57d52ec98fc9c2f249fcf0fffa51c7c6 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Tue, 21 Apr 2020 22:13:53 -0500 Subject: [PATCH] added some simple tests --- README.md | 2 +- async-git/Cargo.toml | 1 + async-git/README.md | 18 ++++++++++++++++++ async-git/run-tests.sh | 11 +++++++++++ async-git/tests/helper.sh | 16 ++++++++++++++++ async-git/tests/test-0001-init.sh | 19 +++++++++++++++++++ async-zlib/Cargo.toml | 1 + async-zlib/src/deflate/deflate.rs | 0 async-zlib/src/deflate/mod.rs | 1 + async-zlib/src/lib.rs | 1 + 10 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 async-git/README.md create mode 100755 async-git/run-tests.sh create mode 100755 async-git/tests/helper.sh create mode 100755 async-git/tests/test-0001-init.sh create mode 100644 async-zlib/src/deflate/deflate.rs create mode 100644 async-zlib/src/deflate/mod.rs diff --git a/README.md b/README.md index d5edbd5..c201368 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,4 @@ Contact Author: Michael Zhang -License: MIT/Apache Dual License +License: MIT/Apache-2.0 Dual License diff --git a/async-git/Cargo.toml b/async-git/Cargo.toml index d1390f8..55ad02e 100644 --- a/async-git/Cargo.toml +++ b/async-git/Cargo.toml @@ -3,6 +3,7 @@ name = "async-git" version = "0.1.0" authors = ["Michael Zhang "] edition = "2018" +license = "MIT/Apache-2.0" [[bin]] name = "git" diff --git a/async-git/README.md b/async-git/README.md new file mode 100644 index 0000000..991ce7d --- /dev/null +++ b/async-git/README.md @@ -0,0 +1,18 @@ +async-git +========= + +Pure-rust async implementation of Git. Built on tokio. + +Tests +----- + +Tests are written in bash. Run `run-tests.sh` to invoke them. + +Set the `GIT_PATH` environment variable to a different path to test a different Git implementation. + +Contact +------- + +Author: Michael Zhang + +License: MIT/Apache-2.0 Dual License diff --git a/async-git/run-tests.sh b/async-git/run-tests.sh new file mode 100755 index 0000000..3159c22 --- /dev/null +++ b/async-git/run-tests.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# get the directory where this script lives +DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)" +export GIT_PATH=${GIT_PATH:-$DIR/../target/debug/git} +export TESTS_DIR=${TESTS_DIR:-$DIR/tests} + +for script in $(ls $TESTS_DIR/test-*.sh); +do + (cd $TESTS_DIR; bash $script) +done \ No newline at end of file diff --git a/async-git/tests/helper.sh b/async-git/tests/helper.sh new file mode 100755 index 0000000..a821c68 --- /dev/null +++ b/async-git/tests/helper.sh @@ -0,0 +1,16 @@ +function get_temp_name { + temp_dir=$(mktemp -u -d -t $1-XXXXXXXX) +} + +function error { + echo $* > /dev/stderr + false +} + +function file_exists { + [[ -f $1 ]] || error "file $1 doesn't exist" +} + +function dir_exists { + [[ -d $1 ]] || error "directory $1 doesn't exist" +} \ No newline at end of file diff --git a/async-git/tests/test-0001-init.sh b/async-git/tests/test-0001-init.sh new file mode 100755 index 0000000..2f06371 --- /dev/null +++ b/async-git/tests/test-0001-init.sh @@ -0,0 +1,19 @@ +set -e + +. helper.sh +TEST_NAME=test-0001-init + +function check_initial_layout { + # does it actually create the required directories? + file_exists "$1/HEAD" + dir_exists "$1/refs" +} + +# does git init work without failing? +get_temp_name $TEST_NAME +$GIT_PATH init $temp_dir +if [ ! $? ]; then + error "git init failed" +fi + +check_initial_layout "$temp_dir/.git" diff --git a/async-zlib/Cargo.toml b/async-zlib/Cargo.toml index f712159..ae8d021 100644 --- a/async-zlib/Cargo.toml +++ b/async-zlib/Cargo.toml @@ -3,6 +3,7 @@ name = "async-zlib" version = "0.1.0" authors = ["Michael Zhang "] edition = "2018" +license = "MIT/Apache-2.0" [dependencies] tokio = { version = "0.2.18", default-features = false, features = ["fs", "macros"] } diff --git a/async-zlib/src/deflate/deflate.rs b/async-zlib/src/deflate/deflate.rs new file mode 100644 index 0000000..e69de29 diff --git a/async-zlib/src/deflate/mod.rs b/async-zlib/src/deflate/mod.rs new file mode 100644 index 0000000..d174576 --- /dev/null +++ b/async-zlib/src/deflate/mod.rs @@ -0,0 +1 @@ +mod deflate; diff --git a/async-zlib/src/lib.rs b/async-zlib/src/lib.rs index a908f83..72921f6 100644 --- a/async-zlib/src/lib.rs +++ b/async-zlib/src/lib.rs @@ -1,4 +1,5 @@ mod decoder; +mod deflate; mod encoder; pub use crate::decoder::ZlibDecoder;