This repository was archived by the owner on Oct 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrefresh_cached_responses.sh
executable file
·71 lines (57 loc) · 1.92 KB
/
refresh_cached_responses.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Copyright 2017 The Chromium Authors.
#
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd.
set -e
remove=0
skip=1
while getopts rs opt; do
case $opt in
r) remove=1 ;;
s) skip=0 ;;
*) exit 1
esac
done
if [[ ( $remove = 0 ) && ( $skip = 1 ) ]]; then
cat <<EOF
You are about to purge all files from codesearch/testdata/responses/* and
replace them with fresh files from the current CodeSearch index. This is a
destructive operation. If you really meant to do this, rerun this command with
the '-r' option. I.e.:
sh refresh_cached_responses.sh -r
The script will remove all the cached response files and rerun the tests.
Whenever one of the tests makes a request for a resource, that test will fail
and a *.missing file will be created. This .missing file contains all the
details necessary to make a network request for teh missing resource. Then the
script invokes codesearch/testing_support.py to fetch the missing resource.
This operation will repeat until there are no more missing resources.
Assuming the tests are successful, then you'll end up with a bunch of files
deleted from the git index, and also a bunch of files that were added. All the
tests should pass. If not, you'd need to figure out what's going on.
EOF
exit 1
fi
set +e
if [ $remove = 1 ]; then
git rm codesearch/testdata/responses/\* || echo No files in index.
rm codesearch/testdata/responses/* || echo No unresolved files in cache.
if [[ ! ( -d codesearch/testdata/responses ) ]]; then
mkdir -p codesearch/testdata/responses
fi
fi
files_added=0
./run_tests.sh
while [ $? != 0 ]; do
echo Attempting to resolve missing resources.
python codesearch/testing_support.py
if [ $? != 0 ]; then
exit 1
fi
files_added=1
./run_tests.sh
done
if [ $files_added == 1 ]; then
git add codesearch/testdata/responses
fi