blob: 457f4e3019a2f031a9e8cb665aca91e42cd269e7 [file] [log] [blame]
Dan Willemsena42898a2018-06-09 12:09:27 -07001#!/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
17set -u
18
19mk="$@"
20
21cat <<EOF > Makefile
22test: out/foo.o
23test2:
24out/foo.o: foo.c foo.h test2
25 @echo "END"
26foo.c:
27 @exit 0
28foo.h: foo.c
29
30.PHONY: test test2
31EOF
32
33# TODO: test implicit outputs
34
35if 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'
40else
41 ${mk} --writable=out/ 2>&1
42fi
43
44if 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"'
47else
48 ${mk} --writable=out/ --werror_writable 2>&1
49fi