mirror of
https://github.com/MinecraftServerControl/mscs.git
synced 2024-11-15 06:48:16 -07:00
make getValue return values with hyphens
This commit is contained in:
parent
2b9ad470e3
commit
5c94830f7b
2
msctl
2
msctl
@ -606,7 +606,7 @@ getValue() {
|
||||
# $VALUE may contains flag-like strings not intended for printf
|
||||
printf -- "$VALUE"
|
||||
else
|
||||
printf "$3"
|
||||
printf -- "$3"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ terr () {
|
||||
|
||||
# funcs like getMSCSValue have local vars based on WORLDS_LOCATION.
|
||||
WORLDS_LOCATION=/tmp
|
||||
MSCS_DEFAULTS="/tmp/mscs.defaults"
|
||||
testworld="mscs-testdata"
|
||||
# tests will write to this propfile to verify parsing etc.
|
||||
propfile="$WORLDS_LOCATION/$testworld/mscs.properties"
|
||||
|
@ -1,3 +1,6 @@
|
||||
# start with clean slate
|
||||
[ -f $MSCS_DEFAULTS ] && rm $MSCS_DEFAULTS
|
||||
|
||||
want='$JVM_ARGS'
|
||||
# verify DEFAULT_SERVER_COMMAND contains $JVM_ARGS string literal before -jar flag
|
||||
if ! printf "$DEFAULT_SERVER_COMMAND" | grep -qs -- ".*$want.*-jar"; then
|
||||
@ -49,6 +52,27 @@ if [ "$got" != "$want" ]; then
|
||||
terr wrong value from getMSCSValue got \"$got\" want \"$want\"
|
||||
fi
|
||||
|
||||
want="-Dlog4j.configurationFile=/opt/mscs/log4j2.xml"
|
||||
# write the config under test
|
||||
cat > $MSCS_DEFAULTS <<EOF
|
||||
mscs-default-jvm-args=$want
|
||||
EOF
|
||||
got=$(getDefaultsValue "mscs-default-jvm-args" '')
|
||||
# verify getDefaultsValue returns correct value for mscs-default-jvm-args when set
|
||||
if [ "$got" != "$want" ]; then
|
||||
terr "wrong value from getDefaultsValue for mscs-default-jvm-args got $got want $want"
|
||||
fi
|
||||
|
||||
want="-Dlog4j.configurationFile=/opt/mscs/log4j2.xml"
|
||||
cat > $MSCS_DEFAULTS <<EOF
|
||||
mscs-default-jvm-args=
|
||||
EOF
|
||||
# when getValue returns a default value with a hyphen (like a flag)
|
||||
got=$(getValue $MSCS_DEFAULTS mscs-default-jvm-args "$want")
|
||||
if [ "$got" != "$want" ]; then
|
||||
terr "wrong value from getValue for mscs-default-jvm-args got $got want $want"
|
||||
fi
|
||||
|
||||
# verify mscs_defaults output contains correct value for mscs-default-jvm-args
|
||||
got=`mscs_defaults | grep -- '^\# mscs-default-jvm-args=$'`
|
||||
if [ $? -ne 0 ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user