• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2#
3# Copyright 2015 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 -e
18
19log=/tmp/log
20mk="$@"
21
22sleep_if_necessary() {
23  if [ x$(uname) != x"Linux" -o x"${TRAVIS}" != x"" ]; then
24    sleep "$@"
25  fi
26}
27
28export VAR=hoge
29
30cat <<EOF > Makefile
31all:
32	echo foo
33EOF
34
35${mk} 2> ${log}
36if [ -e ninja.sh ]; then
37  ./ninja.sh
38fi
39
40sleep_if_necessary 1
41cat <<EOF > Makefile
42all:
43	echo bar
44	echo VAR=\$(VAR)
45	echo VAR2=\$(VAR2)
46	echo wildcard=\$(wildcard *.mk)
47other:
48	echo foo
49EOF
50
51${mk} 2> ${log}
52if [ -e ninja.sh ]; then
53  if ! grep regenerating ${log} > /dev/null; then
54    echo 'Should be regenerated (Makefile)'
55  fi
56  ./ninja.sh
57fi
58
59export VAR=fuga
60${mk} 2> ${log}
61if [ -e ninja.sh ]; then
62  if ! grep regenerating ${log} > /dev/null; then
63    echo 'Should be regenerated (env changed)'
64  fi
65  ./ninja.sh
66fi
67
68export VAR2=OK
69${mk} 2> ${log}
70if [ -e ninja.sh ]; then
71  if ! grep regenerating ${log} > /dev/null; then
72    echo 'Should be regenerated (env added)'
73  fi
74  ./ninja.sh
75fi
76
77export PATH=/random_path:$PATH
78${mk} 2> ${log}
79if [ -e ninja.sh ]; then
80  if ! grep regenerating ${log} > /dev/null; then
81    echo 'Should be regenerated (PATH changed)'
82  fi
83  ./ninja.sh
84fi
85
86sleep_if_necessary 1
87touch PASS.mk
88${mk} 2> ${log}
89if [ -e ninja.sh ]; then
90  if ! grep regenerating ${log} > /dev/null; then
91    echo 'Should be regenerated (wildcard)'
92  fi
93  ./ninja.sh
94fi
95
96sleep_if_necessary 1
97touch XXX
98${mk} 2> ${log}
99if [ -e ninja.sh ]; then
100  if grep regenerating ${log}; then
101    echo 'Should not be regenerated'
102  fi
103  ./ninja.sh
104fi
105
106${mk} other 2> ${log}
107if [ -e ninja.sh ]; then
108  if ! grep regenerating ${log} >/dev/null; then
109    echo 'Should be regenerated (argument)'
110  fi
111  ./ninja.sh other
112fi
113