Skip to content

Commit

Permalink
Add a test that goes from xml to csv and back
Browse files Browse the repository at this point in the history
  • Loading branch information
hvrauhal committed Jun 20, 2022
1 parent af8c314 commit 98588d3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
16 changes: 12 additions & 4 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#!/usr/bin/env bash
set -Eeuo pipefail

SCRIPT_DIR="$(dirname "$0")"
TEST_DIR="$SCRIPT_DIR/tests/xml-to-csv"
OUT="$TEST_DIR/out/actual.csv"
EXPECTED="$TEST_DIR/expected.csv"
./strings_to_csv.py "$OUT" "$SCRIPT_DIR/tests/xml-to-csv/in"
diff -s "$EXPECTED" "$OUT" && echo "Success" || echo "Failed, $OUT did not equal $EXPECTED see diff above"
ACTUAL_CSV="$TEST_DIR/out/actual.csv"
EXPECTED_CSV="$TEST_DIR/expected.csv"
ORIGINAL_XML="$SCRIPT_DIR/tests/xml-to-csv/in"
./strings_to_csv.py "$ACTUAL_CSV" "$ORIGINAL_XML"
diff -us "$EXPECTED_CSV" "$ACTUAL_CSV"

./csv_to_strings.py "$ACTUAL_CSV" "$SCRIPT_DIR/tests/csv-to-xml/out"
ACTUAL_XML="$SCRIPT_DIR/tests/csv-to-xml/out"
diff -us "$ORIGINAL_XML/values/strings.xml" "$ACTUAL_XML/values/strings.xml"
diff -us "$ORIGINAL_XML/values-sv/strings.xml" "$ACTUAL_XML/values-sv/strings.xml"
diff -us "$ORIGINAL_XML/values-fi/strings.xml" "$ACTUAL_XML/values-fi/strings.xml"
11 changes: 7 additions & 4 deletions tests/xml-to-csv/in/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<resources>
<string name="app_name">My Magnificient App</string>
<string name="ampersanded">Something &amp; other</string>
<string name="app_name">My Magnificient App</string>
<string name="basic">Basic</string>
<string name="bold">Not bold<annotation font="bold">this is bold</annotation> and this is not, then again <annotation font="bold">this is</annotation> this is not</string>
<string name="bold_as_first"><annotation font="bold">this is bold</annotation> and this is not, then again <annotation font="bold">this is</annotation> this is not</string>
<string name="bold_as_last"><annotation font="bold">this is bold</annotation> and this is not, then again <annotation font="bold">bold</annotation></string>
<string name="bold_as_first">
<annotation font="bold">this is bold</annotation> and this is not, then again <annotation font="bold">this is</annotation> this is not</string>
<string name="bold_as_last">
<annotation font="bold">this is bold</annotation> and this is not, then again <annotation font="bold">bold</annotation>
</string>
<string name="english_in_native">English</string>
<string name="missing_translation_from_both_others">Missing translation in both others</string>
<string name="missing_translation_from_one_other">Missing translation in one other</string>
Expand All @@ -14,4 +17,4 @@
<item quantity="other">%1$d items</item>
<item quantity="zero">no items</item>
</plurals>
</resources>
</resources>

0 comments on commit 98588d3

Please sign in to comment.