You've already forked bash-ini-parser
mirror of
https://github.com/albfan/bash-ini-parser.git
synced 2025-08-09 05:22:44 +03:00
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
t/test-results/
|
40
t/Makefile
Normal file
40
t/Makefile
Normal file
@@ -0,0 +1,40 @@
|
||||
SHELL_PATH ?= $(SHELL)
|
||||
PROVE ?= prove
|
||||
DEFAULT_TEST_TARGET ?= test
|
||||
|
||||
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
|
||||
|
||||
T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
|
||||
|
||||
all: $(DEFAULT_TEST_TARGET)
|
||||
|
||||
test: pre-clean
|
||||
@$(MAKE) aggregate-results-and-cleanup
|
||||
|
||||
prove: pre-clean
|
||||
@echo '*** prove ***'; prove --exec '$(SHELL_PATH_SQ)' $(PROVE_OPTS) $(T) :: $(TEST_OPTS)
|
||||
@$(MAKE) clean-except-prove-cache
|
||||
|
||||
aggregate-results:
|
||||
@for f in test-results/t*-*.counts; do \
|
||||
echo "$$f"; \
|
||||
done | '$(SHELL_PATH_SQ)' ./sharness/aggregate-results.sh
|
||||
|
||||
pre-clean:
|
||||
@$(RM) -r test-results
|
||||
|
||||
clean-except-prove-cache:
|
||||
@$(RM) -r 'trash directory'.* test-results
|
||||
|
||||
clean: clean-except-prove-cache
|
||||
@$(RM) .prove
|
||||
|
||||
aggregate-results-and-cleanup: $(T)
|
||||
@$(MAKE) aggregate-results
|
||||
@$(MAKE) clean
|
||||
|
||||
$(T):
|
||||
@echo '*** $@ ***'; '$(SHELL_PATH_SQ)' $@
|
||||
|
||||
.PHONY: all test prove aggregate-results $(T)
|
||||
.PHONY: pre-clean clean-except-prove-cache clean aggregate-results-and-cleanup
|
33
t/README.md
Normal file
33
t/README.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# test suite
|
||||
|
||||
This test suite is based on [sharness](http://mlafeldt.github.io/sharness/)
|
||||
|
||||
## install
|
||||
|
||||
It is installed (from toplevel dir) with:
|
||||
|
||||
git subtree add --squash --prefix t/sharness https://github.com/mlafeldt/sharness master
|
||||
|
||||
and update from time to time with:
|
||||
|
||||
git subtree pull --squah --prefix t/sharness master
|
||||
|
||||
Read http://blogs.atlassian.com/2013/05/alternatives-to-git-submodule-git-subtree/ for more info on git subtree, you can define a remote to simplify commands or contribute sharness from your fork
|
||||
|
||||
## automation
|
||||
|
||||
Although every test is executable by itselft an only depends on sharness, that's not operative. this test suite relays on [prove](http://search.cpan.org/dist/Test-Harness/bin/prove) and ancient and good-know [make](http://www.gnu.org/software/make/) to complete the test suite. Launch it with
|
||||
|
||||
make
|
||||
|
||||
or
|
||||
|
||||
make DEFAULT_TEST_TARGET=prove
|
||||
|
||||
## Credits
|
||||
|
||||
Makefile was shamelessly stolen from [git-integration](https://github.com/johnkeeping/git-integration/blob/master/t/Makefile)
|
||||
|
||||
Test cases are strongly based on [bash_ini_parser test suite](https://github.com/rudimeier/bash_ini_parser/blob/master/test/test.sh)
|
||||
|
||||
|
30
t/t0000-test-setup.sh
Executable file
30
t/t0000-test-setup.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description="Show basic features of Sharness"
|
||||
|
||||
. sharness/sharness.sh
|
||||
|
||||
test_expect_success "Success is reported like this" "
|
||||
echo hello world | grep hello
|
||||
"
|
||||
|
||||
test_expect_success "Commands are chained this way" "
|
||||
test x = 'x' &&
|
||||
test 2 -gt 1 &&
|
||||
echo success
|
||||
"
|
||||
|
||||
return_42() {
|
||||
echo "Will return soon"
|
||||
return 42
|
||||
}
|
||||
|
||||
test_expect_success "You can test for a specific exit code" "
|
||||
test_expect_code 42 return_42
|
||||
"
|
||||
|
||||
test_expect_failure SKIP "We expect this to fail" "
|
||||
test 1 = 2
|
||||
"
|
||||
|
||||
test_done
|
19
t/t0001-parse.sh
Executable file
19
t/t0001-parse.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
SHARNESS_TEST_EXTENSION="sh"
|
||||
|
||||
test_description="check parse"
|
||||
|
||||
. sharness/sharness.sh
|
||||
|
||||
. ../../bash-ini-parser
|
||||
|
||||
DIR_TEST=$SHARNESS_TEST_DIRECTORY/t0001
|
||||
|
||||
test_expect_success "Whitespace parse" "
|
||||
cfg_parser $DIR_TEST/test1.ini &&
|
||||
cfg_writer > test1.out &&
|
||||
diff -u test1.out $DIR_TEST/test1.out.correct
|
||||
"
|
||||
|
||||
test_done
|
17
t/t0001/test1.ini
Normal file
17
t/t0001/test1.ini
Normal file
@@ -0,0 +1,17 @@
|
||||
;seccion one: clean whitespace
|
||||
[sec1]
|
||||
var1 = foo
|
||||
var2 =hoge
|
||||
var3 = fuga
|
||||
var4= pivo
|
||||
[sec2]
|
||||
;this is the variable we want
|
||||
var1=bar
|
||||
var2=foo
|
||||
var3=eco
|
||||
;this is a multiword value
|
||||
var4="piyo baz qux"
|
||||
;this is an array
|
||||
var5=foo bar baz hoge
|
||||
var6=hoge
|
||||
|
13
t/t0001/test1.out.correct
Normal file
13
t/t0001/test1.out.correct
Normal file
@@ -0,0 +1,13 @@
|
||||
[sec1]
|
||||
var1="foo"
|
||||
var2="hoge"
|
||||
var3="fuga"
|
||||
var4="pivo"
|
||||
[sec2]
|
||||
var1="bar"
|
||||
var2="foo"
|
||||
var3="eco"
|
||||
var4="piyo baz qux"
|
||||
;var5 is an array
|
||||
var5="foo bar baz hoge"
|
||||
var6="hoge"
|
Reference in New Issue
Block a user