Skip to content

Commit 4b297c8

Browse files
committed
Updating to handle comments in test properties
1 parent 2f21b1e commit 4b297c8

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

test/test.sh

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
1-
#!/bin/bash
1+
#!/bin/bash
22

33
# Test helper script for jprops
44
#
55
# Kishan Thomas <kishan.thomas@gmail.com>
66

77
RED='\033[0;31m'
88
GREEN='\033[0;32m'
9-
NC='\033[0m' # No Color
9+
NC='\033[0m'
1010

1111
# Import jprops from parent folder
1212
export PYTHONPATH="../:$PYTHONPATH"
1313

14-
# The expected properties
15-
PROPERTY_COUNT=$(wc -l test.properties|awk '{ print $1}')
16-
1714
# Use Java and get all the properties ordered by key from test.properties
1815
javac Test.java
1916
java Test > java.props.out
2017
# Use Python jprops and get all the properties ordered by key from test.properties
18+
#python test.py > python.props.out
2119
python test.py > python.props.out
2220

2321
JAVA_COUNT=$( expr $(wc -l java.props.out|awk '{ print $1}') - 2 )
2422
PYTHON_COUNT=$( expr $(wc -l python.props.out|awk '{ print $1}') - 2 )
2523

26-
# Check both Java and Python jprops found the same number of properties from the same test.properties
27-
echo "Expected $PROPERTY_COUNT, Java found $JAVA_COUNT, Python jprops found $PYTHON_COUNT"
24+
# Check both Java and Python jprops found the same number of properties from the same test.properties
25+
echo "Java found $JAVA_COUNT properties, Python jprops found $PYTHON_COUNT properties from test.properties"
2826

29-
if [ $JAVA_COUNT != $PROPERTY_COUNT ] || [ $PYTHON_COUNT != $PROPERTY_COUNT ]
30-
then
31-
diff java.props.out python.props.out
32-
echo -e "${RED}Test Fail: The properties count $JAVA_COUNT (Java) and/or $PYTHON_COUNT (jprops) do not match the expected count $PROPERTY_COUNT ${NC}"
27+
if [ $JAVA_COUNT != $PYTHON_COUNT ]
28+
then
29+
diff java.props.out python.props.out
30+
echo -e "${RED}Test Fail: The properties counted by Java $JAVA_COUNT, does not math the count from Python jprops $PYTHON_COUNT${NC}"
3331
exit 1
3432
else
35-
echo -e "${GREEN}Test Pass: The properties count $PYTHON_COUNT match the expected count $PROPERTY_COUNT ${NC}"
36-
fi
33+
echo -e "${GREEN}Test Pass: The properties count $PYTHON_COUNT match the expected count $JAVA_COUNT ${NC}"
34+
fi
3735

38-
# Both outputs are ordered by key and formatted in matching format (json)
36+
# Both outputs are ordered by key and formatted in matching format (json)
3937
# So a simple diff can find if they both match TODO: Use a json tool for matching
40-
if diff java.props.out python.props.out; then
41-
echo -e "${GREEN}Test Pass: All $PROPERTY_COUNT properties match${NC}"
38+
if diff java.props.out python.props.out; then
39+
echo -e "${GREEN}Test Pass: All $JAVA_COUNT properties match${NC}"
4240
else
43-
echo -e "${RED}Test Fail: Not all $PROPERTY_COUNT properties match${NC}"
41+
echo -e "${RED}Test Fail: Not all $JAVA_COUNT properties match${NC}"
4442
exit 1
4543
fi

0 commit comments

Comments
 (0)