Merge pull request #1092 from matthiasbeyer/minor

Minor things
This commit is contained in:
Matthias Beyer 2017-09-20 19:24:44 +02:00 committed by GitHub
commit b431d0ee49
9 changed files with 5 additions and 420 deletions

View file

@ -60,8 +60,9 @@ install-directory is in your `$PATH`), or install the `imag` binary to call `ima
## Staying up-to-date ## Staying up-to-date
We have a [official website for imag](https://imag-pim.org), where I post We have a [official website for imag](https://imag-pim.org), where I post
[release notes](http://imag-pim.org/releases/) and monthly(ish) updates what's happening in the source tree. [release notes](http://imag-pim.org/releases/) and monthly(ish) updates what's
There is no RSS feed, though. happening in the source tree ([RSS here](https://imag-pim.org/index.xml)).
We also have a [mailinglist](https://imag-pim.org/mailinglist/) where I post We also have a [mailinglist](https://imag-pim.org/mailinglist/) where I post
updates and where discussion and questions are encouraged. updates and where discussion and questions are encouraged.

View file

@ -1,175 +0,0 @@
#!/usr/bin/env bash
source $(dirname ${BASH_SOURCE[0]})/../../tests/utils.sh
source $(dirname ${BASH_SOURCE[0]})/utils.sh
test_call() {
imag-store create -p test-call
if [[ ! $? -eq 0 ]]; then
err "Return value should be zero, was non-zero"
return 1;
fi
}
test_call_id() {
imag-store create -i test-call
if [[ ! $? -eq 0 ]]; then
err "Return value should be zero, was non-zero"
return 1;
fi
}
test_call_no_id() {
imag-store create
if [[ ! $? -eq 1 ]]; then
err "Return value should be zero, was non-zero"
return 1;
fi
}
test_mkstore() {
imag-store create -p test-mkstore || { err "Calling imag failed"; return 1; }
if [[ -d ${STORE} ]]; then
out "Store exists."
else
err "No store created"
return 1
fi
}
test_std_header() {
local expected=$(cat <<EOS
---
[imag]
links = []
version = "0.4.0"
---
EOS
)
imag-store create -p test-std-header
local result=$(cat ${STORE}/test-std-header)
if [[ "$expected" == "$result" ]]; then
out "Expected store entry == result"
else
err "${STORE}/test-std-header differs from expected"
return 1
fi
}
test_std_header_plus_custom() {
local expected=$(cat <<EOS
---
[imag]
links = []
version = "0.4.0"
[zzz]
zzz = "z"
---
EOS
)
imag-store create -p test-std-header-plus-custom entry -h zzz.zzz=z
local result=$(cat ${STORE}/test-std-header-plus-custom)
if [[ "$expected" == "$result" ]]; then
out "Expected store entry == result"
else
err "${STORE}/test differs from expected"
return 1
fi
}
test_std_header_plus_custom_multiheader() {
local expected=$(cat <<EOS
---
[foo]
bar = "baz"
[imag]
links = []
version = "0.4.0"
[zzz]
zzz = "z"
---
EOS
)
local filename="test-std-header-plus-custom-multiheader"
imag-store create -p $filename entry -h zzz.zzz=z foo.bar=baz
local result=$(cat ${STORE}/$filename)
if [[ "$expected" == "$result" ]]; then
out "Expected store entry == result"
else
err "${STORE}/$filename differs from expected"
return 1
fi
}
test_std_header_plus_custom_multiheader_same_section() {
local expected=$(cat <<EOS
---
[imag]
links = []
version = "0.4.0"
[zzz]
bar = "baz"
zzz = "z"
---
EOS
)
local filename="test-std-header-plus-custom-mutliheader-same-section"
imag-store create -p $filename entry -h zzz.zzz=z zzz.bar=baz
local result=$(cat ${STORE}/$filename)
if [[ "$expected" == "$result" ]]; then
out "Expected store entry == result"
else
err "${STORE}/$filename differs from expected"
return 1
fi
}
test_std_header_plus_custom_and_content() {
local expected=$(cat <<EOS
---
[imag]
links = []
version = "0.4.0"
[zzz]
zzz = "z"
---
content
EOS
)
local name="test-std-header-plus-custom-and-content"
imag-store create -p $name entry -h zzz.zzz=z -c content
local result=$(cat ${STORE}/$name)
if [[ "$expected" == "$result" ]]; then
out "Expected store entry == result"
else
err "${STORE}/test differs from expected"
return 1
fi
}
invoke_tests \
test_call \
test_call_id \
test_call_no_id \
test_mkstore \
test_std_header \
test_std_header_plus_custom \
test_std_header_plus_custom_multiheader \
test_std_header_plus_custom_multiheader_same_section \
test_std_header_plus_custom_and_content

View file

@ -1,85 +0,0 @@
#!/usr/bin/env bash
source $(dirname ${BASH_SOURCE[0]})/../../tests/utils.sh
source $(dirname ${BASH_SOURCE[0]})/utils.sh
std_header() {
cat <<EOS
---
[imag]
links = []
version = "0.4.0"
---
EOS
}
retrieve() {
silent imag-store retrieve $*
}
test_retrieve_nothing() {
local id="test-retrieve_nothing"
imag-store create -p ${id} || { err "create failed"; return 1; }
out "Going to test the retrieve functionality now"
local zero_out="$(retrieve --id ${id})" || return 1
out "Retrieving for zero_out finished"
if [[ ! -z "$zero_out" ]]; then
err "Expected zero output, got '$zero_out'"
return 1
fi
}
test_retrieve_content() {
local id="test-retrieve_simple"
imag-store create -p ${id} || { err "create failed"; return 1; }
out "Going to test the retrieve functionality now"
local content_out="$(retrieve --id ${id} --content)" || return 1
out "Retrieving for content_out finished"
if [[ ! -z "$content_out" ]]; then
err "Expected content output == zero output, got '$content_out'"
return 1
fi
}
test_retrieve_header() {
local id="test-retrieve_simple"
imag-store create -p ${id} || { err "create failed"; return 1; }
out "Going to test the retrieve functionality now"
local header_out="$(retrieve --id ${id} --header)"
out "Retrieving for header_out finished"
if [[ ! "$header_out" != "$(std_header)" ]]; then
err "Expected header as output, got '$header_out'"
return 1
fi
}
test_retrieve_raw() {
local id="test-retrieve_simple"
imag-store create -p ${id} || { err "create failed"; return 1; }
out "Going to test the retrieve functionality now"
local both_out="$(retrieve --id ${id} --raw)"
out "Retrieving for both_out finished"
if [[ "$both_out" != "$(std_header)" ]]; then
err "Expected "$(std_header)" as output, got '$both_out'"
return 1
fi
}
invoke_tests \
test_retrieve_nothing \
test_retrieve_content \
test_retrieve_header \
test_retrieve_raw

View file

@ -1,30 +0,0 @@
#!/usr/bin/env bash
source $(dirname ${BASH_SOURCE[0]})/../../tests/utils.sh
source $(dirname ${BASH_SOURCE[0]})/utils.sh
create() {
imag-store create $*
}
delete() {
imag-store delete $*
}
test_delete_simple() {
local name="test"
create -p $name
delete --id $name
local n=$($(find ${STORE}/ -type f | wc -l))
if [[ $n -eq 0 ]]; then
success "Deleting worked"
else
err "There are still $n files in the store"
fi
}
invoke_tests \
test_delete_simple

View file

@ -1,14 +0,0 @@
ECHO=$(shell which echo) -e
TARGETS=$(shell find -name "*test.sh" -type f)
BASH=$(shell which bash)
all: $(TARGETS)
@$(ECHO) $(TARGETS)
$(TARGETS): %: .FORCE
@$(ECHO) "\t[BASH ]:\t$@"
@$(BASH) $@
.FORCE:

View file

@ -1,6 +0,0 @@
source $(dirname ${BASH_SOURCE[0]})/../../tests/utils.sh
imag-store() {
imag-call-binary "$(dirname ${BASH_SOURCE[0]})/../../target/debug/" imag-store $*
}

View file

@ -1 +1 @@
../doc/src/05100-lib-interaction.md ../../../doc/src/05100-lib-interaction.md

View file

@ -1 +1 @@
../doc/src/05100-lib-util.md ../../../doc/src/05100-lib-util.md

View file

@ -1,106 +0,0 @@
#!/usr/bin/env bash
#
#
# This file contains test utility functions which are used by the test scripts
# for each binary.
#
#
COLOR_OFF='\e[0m' # Text Reset
RED='\e[0;31m' # Red
YELLOW='\e[0;33m' # Yellow
GREEN='\e[0;32m' # Green
RUNTIME="/tmp"
STORE="${RUNTIME}/store"
out() {
[[ -z "$DEBUG_OUTPUT_OFF" ]] && echo -e "${YELLOW}:: $*${COLOR_OFF}"
}
success() {
[[ -z "$DEBUG_OUTPUT_OFF" ]] && echo -e "${GREEN}>> $*${COLOR_OFF}"
}
err() {
[[ -z "$DEBUG_OUTPUT_OFF" ]] && echo -e "${RED}!! $*${COLOR_OFF}"
}
silent() {
DEBUG_OUTPUT_OFF=1 $*
}
imag-call-binary() {
local searchdir=$1; shift
local binary=$1; shift
[[ -d $searchdir ]] || { err "FATAL: No directory $searchdir"; exit 1; }
local bin=$(find $searchdir -iname $binary -type f -executable)
local flags="--no-color --config ./imagrc.toml --override-config store.implicit-create=true --rtp $RUNTIME"
out "Calling '$bin $flags $*'"
$bin $flags $*
}
cat_entry() {
cat ${STORE}/$1
}
reset_store() {
rm -rf "${STORE}"/.git
rm -r "${STORE}"
}
call_test() {
prepare_store_directory || {
err "Preparing store directory failed"
exit 1
}
out "-- TESTING: '$1' --"
$1
result=$?
if [[ -z "$DONT_RESET_STORE" ]]; then
out "Reseting store"
reset_store
out "Store reset done"
fi
[[ $result -eq 0 ]] || { err "-- FAILED: '$1'. Exiting."; exit 1; }
success "-- SUCCESS: '$1' --"
}
__git() {
out "Calling git: $*"
git --work-tree=/tmp/store/ --git-dir=/tmp/store/.git $*
}
__git_commit() {
out "Calling git-commit: $*"
git --work-tree=/tmp/store/ --git-dir=/tmp/store/.git commit -m "$*"
}
prepare_store_directory() {
out "Preparing /tmp/store"
mkdir -p /tmp/store/ &&\
touch /tmp/store/.gitkeep &&\
__git init &&\
__git config --local user.email "imag@imag-pim.org" &&\
__git config --local user.name "Imag CI" &&\
__git add .gitkeep &&\
__git_commit 'Initial commit: .gitkeep'
}
invoke_tests() {
out "Invoking tests."
if [[ ! -z "$INVOKE_TEST" ]]; then
out "Invoking only $INVOKE_TEST"
call_test "$INVOKE_TEST"
else
out "Invoking $*"
for t in $*; do
call_test "$t"
done
fi
}