1
0
mirror of https://github.com/albfan/bash-ini-parser.git synced 2025-08-06 07:02:37 +03:00

test invalid ini files

it is break by now

relates to #4
This commit is contained in:
albfan
2015-05-16 21:35:31 +02:00
parent 389ef3f00f
commit 1be6551065
3 changed files with 27 additions and 1 deletions

View File

@@ -53,11 +53,12 @@ function cfg_parser {
ini[${#ini[*]} + 1]='}' # add the last brace ini[${#ini[*]} + 1]='}' # add the last brace
debug debug
eval "$(echo "${ini[*]}")" # eval the result eval "$(echo "${ini[*]}")" # eval the result
EVAL_STATUS=$?
if [ $CHANGE_EXTGLOB = 1 ] if [ $CHANGE_EXTGLOB = 1 ]
then then
shopt -u extglob shopt -u extglob
fi fi
return $EVAL_STATUS
} }
function cfg_writer { function cfg_writer {

17
t/t0002-invalid.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/sh
SHARNESS_TEST_EXTENSION="sh"
test_description="check invalid ini files"
. sharness/sharness.sh
. ../../bash-ini-parser
DIR_TEST=$SHARNESS_TEST_DIRECTORY/t0002
test_expect_success "Invalid line" "
test_expect_code 1 cfg_parser $DIR_TEST/invalid.ini
"
test_done

8
t/t0002/invalid.ini Normal file
View File

@@ -0,0 +1,8 @@
var1=VAR1
; Invalid line - should throw an error and stop processing
INVALID LINE
var2=VAR2