added some simple tests

This commit is contained in:
Michael Zhang 2020-04-21 22:13:53 -05:00
parent 4217b71413
commit b7a62b8c57
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
10 changed files with 69 additions and 1 deletions

View file

@ -8,4 +8,4 @@ Contact
Author: Michael Zhang
License: MIT/Apache Dual License
License: MIT/Apache-2.0 Dual License

View file

@ -3,6 +3,7 @@ name = "async-git"
version = "0.1.0"
authors = ["Michael Zhang <iptq@protonmail.com>"]
edition = "2018"
license = "MIT/Apache-2.0"
[[bin]]
name = "git"

18
async-git/README.md Normal file
View file

@ -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

11
async-git/run-tests.sh Executable file
View file

@ -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

16
async-git/tests/helper.sh Executable file
View file

@ -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"
}

View file

@ -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"

View file

@ -3,6 +3,7 @@ name = "async-zlib"
version = "0.1.0"
authors = ["Michael Zhang <iptq@protonmail.com>"]
edition = "2018"
license = "MIT/Apache-2.0"
[dependencies]
tokio = { version = "0.2.18", default-features = false, features = ["fs", "macros"] }

View file

View file

@ -0,0 +1 @@
mod deflate;

View file

@ -1,4 +1,5 @@
mod decoder;
mod deflate;
mod encoder;
pub use crate::decoder::ZlibDecoder;