forked from datacommonsorg/mixer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_test.sh
More file actions
executable file
·62 lines (54 loc) · 1.66 KB
/
run_test.sh
File metadata and controls
executable file
·62 lines (54 loc) · 1.66 KB
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
#!/bin/bash
# Copyright 2025 Google LLC
#
# 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
#
# https://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.
# This script is used to run all the mixer tests.
# `./run_test.sh` runs the tests with local Golang enviroment.
# `./run_test.sh -l` runs the linter.
# `./run_test.sh -f` runs the linter and fixes auto-fixable issues.
LINT=false
FIX=false
while getopts 'lf' c
do
case $c in
l) LINT=true ;;
f) FIX=true ;;
*) echo "Unknown option ${OPTARG}"
exit 1
;;
esac
done
set -e
if [ "$FIX" = true ] || [ "$LINT" = true ]; then
if ! [ -x "$(command -v golangci-lint)" ]; then
echo 'Error: golangci-lint is not installed.' >&2
echo 'Install it from https://golangci-lint.run/usage/install/' >&2
exit 1
fi
REQUIRED_VERSION="2.3.0"
if ! golangci-lint --version | grep -q "$REQUIRED_VERSION"; then
echo "Error: wrong golangci-lint version. Want $REQUIRED_VERSION" >&2
echo "Found: $(golangci-lint --version)"
exit 1
fi
fi
if [ "$FIX" = true ]; then
echo "Running golangci-lint with --fix..."
golangci-lint run --fix
elif [ "$LINT" = true ]; then
echo "Running golangci-lint..."
golangci-lint run
else
echo "Running tests..."
go test -v ./...
fi