blob: 8589c1d433fc5f93c5facc350a8efa0e1d6a148d (
plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#!/bin/bash
# Copyright (C) 2024 The Android Open Source Project
#
# 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 -e
SCRIPT_NAME="${0##*/}"
usage() {
cat <<"EOF"
$SCRIPT_NAME: Shrink / unshrink SystemUiRavenTests.
SystemUiRavenTests has a lot of kotlin source files, so it's slow to build,
which is painful when you want to run it after updating ravenwood code
that SystemUiRavenTests depends on. (example: junit-src/)
This script basically removes the test files in SystemUI/multivalentTests
that don't have @EnabledOnRavenwood. But if we actaully remove them,
soong would re-generate the ninja file, which will take a long time,
so instead it'll truncate them.
This script will also tell git to ignore these files, so they won't shw up
in `git status`.
(Use `git ls-files -v | sed -ne "s/^[a-zS] //p"` to show ignored filse.)
Usage:
$SCRIPT_NAME -s # Shrink the test files.
$SCRIPT_NAME -u # Undo it.
EOF
}
TEST_PATH=${ANDROID_BUILD_TOP}/frameworks/base/packages/SystemUI/multivalentTests
cd "$TEST_PATH"
command=""
case "$1" in
"-s") command=shrink ;;
"-u") command=unshrink ;;
*) usage ; exit 1 ;;
esac
echo "Listing test files...."
files=( $(find . -name '*Test.kt' -o -name '*Test.java') )
exemption='(BaseHeadsUpManagerTest)'
shrink() {
local target=()
for file in ${files[@]}; do
# Check for exemption
if echo $file | egrep -q "$exemption"; then
echo " Skip exempted file"
continue
fi
echo "Checking $file"
if ! [[ -f $file ]] ; then
echo " Skip non regular file"
continue
fi
if ! [[ -s $file ]] ; then
echo " Skip empty file"
continue
fi
if grep -q '@EnabledOnRavenwood' $file ; then
echo " Skip ravenwood test file".
continue
fi
# It's a non ravenwood test file. Empty it.
: > $file
# Tell git to ignore the file
target+=($file)
echo " Emptied"
done
if (( ${#target[@]} == 0 )) ; then
echo "No files emptied."
return 0
fi
git update-index --skip-worktree ${target[@]}
echo "Emptied ${#target[@]} files"
return 0
}
unshrink() {
local target=()
# Collect empty files
for file in ${files[@]}; do
if [[ -s $file ]] ; then
continue
fi
target+=($file)
: > $file
done
if (( ${#target[@]} == 0 )) ; then
echo "No files to restore."
return 0
fi
# Un-ignore the files, and check out the original files
echo "Restoring ${#target[@]} files..."
git update-index --no-skip-worktree ${target[@]}
git checkout goog/main ${target[@]}
return 0
}
$command
|