aboutsummaryrefslogtreecommitdiff
path: root/testcase
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2017-04-27 23:39:57 -0700
committerDan Willemsen <dwillemsen@google.com>2017-05-22 21:22:46 -0700
commitf63a3fd971eb9d2a8440237a9191cf2ed22697f5 (patch)
treefd2ee906ecdba73a18687e1dc23f3e6eceb92be0 /testcase
parent96e3c407c473f09a727615c4a83fe0e9c11a6b11 (diff)
Add --werror_find_emulator, --werror_overriding_commands
For Android builds, we'd like to start removing some of the default warnings and turn them into errors so that they can't come back. For find emulator, we could attempt to check for errors, or silence every find command in the tree, but that doesn't particularly scale, especially when new code gets added with warnings. We've gone through and fixed many of these, but they keep coming back, so add --werror_find_emulator so that when we fix them all we can prevent them from coming back. Overriding commands is similar -- we really don't want multiple rules defining a single output file. In ninja we've turned on -w dupbuild=err, but if the paths happen to be identical the makefile overriding logic kicks in first and presents a warning instead of an error. So add --werror_overriding_commands in order to turn the make warning into an error.
Diffstat (limited to 'testcase')
-rw-r--r--testcase/werror_find_emulator.sh40
-rw-r--r--testcase/werror_overriding_commands.sh44
2 files changed, 84 insertions, 0 deletions
diff --git a/testcase/werror_find_emulator.sh b/testcase/werror_find_emulator.sh
new file mode 100644
index 0000000..c18f866
--- /dev/null
+++ b/testcase/werror_find_emulator.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+#
+# Copyright 2017 Google Inc. All rights reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -u
+
+mk="$@"
+
+cat <<EOF > Makefile
+FOO := \$(shell find does/not/exist -name '*.txt')
+all:
+EOF
+
+if echo "${mk}" | grep -qv "kati"; then
+ # Make doesn't use find emulator, or support --werror_find_emulator, so write
+ # expected output.
+ echo 'find: "does/not/exist": No such file or directory'
+ echo 'Nothing to be done for "all".'
+ echo 'Clean exit'
+else
+ ${mk} --use_find_emulator 2>&1 && echo "Clean exit"
+fi
+
+if echo "${mk}" | grep -qv "kati"; then
+ echo 'find: "does/not/exist": No such file or directory'
+else
+ ${mk} --use_find_emulator --werror_find_emulator 2>&1 && echo "Clean exit"
+fi
diff --git a/testcase/werror_overriding_commands.sh b/testcase/werror_overriding_commands.sh
new file mode 100644
index 0000000..e89553d
--- /dev/null
+++ b/testcase/werror_overriding_commands.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+# Copyright 2017 Google Inc. All rights reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -u
+
+mk="$@"
+
+cat <<EOF > Makefile
+test: foo
+foo:
+ @echo "FAIL"
+foo:
+ @echo "PASS"
+EOF
+
+if echo "${mk}" | grep -qv "kati"; then
+ # Make doesn't use find emulator, or support --werror_find_emulator, so write
+ # expected output.
+ echo 'Makefile:5: warning: overriding commands for target "foo"'
+ echo 'Makefile:3: warning: ignoring old commands for target "foo"'
+ echo 'PASS'
+ echo 'Clean exit'
+else
+ ${mk} 2>&1 && echo "Clean exit"
+fi
+
+if echo "${mk}" | grep -qv "kati"; then
+ echo 'Makefile:5: *** overriding commands for target "foo", previously defined at Makefile:3'
+else
+ ${mk} --werror_overriding_commands 2>&1 && echo "Clean exit"
+fi