Merge "Add a chain style to formatter."
diff --git a/test/errors.output b/test/errors.output
new file mode 100644
index 0000000..e3591dc
--- /dev/null
+++ b/test/errors.output
@@ -0,0 +1,28 @@
+ERROR: syntax error at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:16.1-3
+ERROR: missing ; at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:18.32-31
+ERROR: Unable to import 'IBad' at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:21.8-11
+ERROR: missing ; at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:22.13-12
+ERROR: syntax error at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:23.8-11
+ERROR: Unable to import 'IBad' at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:25.8-11
+ERROR: Unable to import 'IBad' at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:27.8-11
+ERROR: syntax error at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:29.23
+ERROR: syntax error at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:35.8
+ERROR: syntax error at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:43.29
+ERROR: Failed to lookup type 'bad' at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:52.9-11
+ERROR: syntax error at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:54.9
+ERROR: missing ; at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:56.32-31
+ERROR: Failed to lookup type 'bad' at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:58.9-11
+ERROR: syntax error at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:61.8
+ERROR: Failed to lookup type 'bad' at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:65.9-11
+ERROR: Failed to lookup type 'bad' at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:71.13-15
+ERROR: ref of interface IEx1 is not supported. at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:73.17-20
+ERROR: Failed to lookup type 'mask' at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:74.13-16
+ERROR: Failed to lookup type 'mask' at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:76.13-16
+ERROR: syntax error at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:80.9-15
+ERROR: Failed to lookup type 'bad' at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:88.9-11
+ERROR: Failed to lookup type 'bad' at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:94.12-14
+ERROR: missing ; at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:96.21-20
+ERROR: missing ; at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:97.20-19
+ERROR: missing ; at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:100.6-5
+ERROR: missing ; at system/tools/hidl/test/errors/syntax/1.0/IEx1.hal:102.2-1
+ERROR: Could not parse tests.errors.syntax@1.0::IEx1. Aborting.
diff --git a/test/test.sh b/test/test.sh
new file mode 100755
index 0000000..ab89e03
--- /dev/null
+++ b/test/test.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+# Run hidl-gen against errors/syntax/1.0/IEx1.hal to ensure it detects as many
+# syntax errors as possible.
+
+if [ ! -d system/tools/hidl/test/errors/syntax/1.0 ] ; then
+  echo "Where is system/tools/hidl/test/errors/syntax/1.0?";
+  exit 1;
+fi
+
+# TODO(b/33276472)
+if [ ! -d system/libhidl/transport ] ; then
+  echo "Where is system/libhidl/transport?";
+  exit 1;
+fi
+
+COMMAND='hidl-gen -Lc++ -rtests:system/tools/hidl/test -randroid.hidl:system/libhidl/transport -o /tmp tests.errors.syntax@1.0'
+EXPECTED='system/tools/hidl/test/errors.output'
+
+if [[ "$@" == "-h" ]]
+then
+    echo "$0 [-h|-u|-n]"
+    echo "    (No options)  Run and diff against expected output"
+    echo "    -u            Update expected output"
+    echo "    -a            Run and show actual output"
+    echo "    -h            Show help text"
+elif [[ "$@" == "-u" ]]
+then
+    $COMMAND 2>$EXPECTED;
+    echo Updated.
+elif [[ "$@" == "-a" ]]
+then
+    $COMMAND
+else
+    $COMMAND 2>&1 | diff $EXPECTED -
+    if [ $? -eq 0 ]; then
+        echo Success.
+    fi
+fi