Dan Willemsen | a42898a | 2018-06-09 12:09:27 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright 2018 Google Inc. All rights reserved |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http:#www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | set -u |
| 18 | |
| 19 | mk="$@" |
| 20 | |
| 21 | cat <<EOF > Makefile |
| 22 | test: out/foo.o |
| 23 | test2: |
| 24 | out/foo.o: foo.c foo.h test2 |
| 25 | @echo "END" |
| 26 | foo.c: |
| 27 | @exit 0 |
| 28 | foo.h: foo.c |
| 29 | |
| 30 | .PHONY: test test2 |
| 31 | EOF |
| 32 | |
| 33 | # TODO: test implicit outputs |
| 34 | |
| 35 | if echo "${mk}" | grep -qv "kati"; then |
| 36 | # Make doesn't support these warnings, so write the expected output. |
| 37 | echo 'Makefile:6: warning: writing to readonly directory: "foo.c"' |
| 38 | echo 'Makefile:7: warning: writing to readonly directory: "foo.h"' |
| 39 | echo 'END' |
| 40 | else |
| 41 | ${mk} --writable=out/ 2>&1 |
| 42 | fi |
| 43 | |
| 44 | if echo "${mk}" | grep -qv "kati"; then |
| 45 | # Make doesn't support these warnings, so write the expected output. |
| 46 | echo 'Makefile:6: *** writing to readonly directory: "foo.c"' |
| 47 | else |
| 48 | ${mk} --writable=out/ --werror_writable 2>&1 |
| 49 | fi |