Skip to content

Commit

Permalink
scripts, tests: update the check-test.sh to detect more inefficient a…
Browse files Browse the repository at this point in the history
…ssert functions (tikv#5219)

ref tikv#4813

Update the check-test.sh to detect more inefficient assert functions.

Signed-off-by: JmPotato <[email protected]>
  • Loading branch information
JmPotato authored and CabinfeverB committed Jul 14, 2022
1 parent ed16b60 commit 29fc365
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 8 additions & 0 deletions scripts/check-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,12 @@ if [ "$res" ]; then
exit 1
fi

res=$(grep -rn --include=\*_test.go -E "(re|suite|require)\.(Equal|NotEqual)\((t, )?(true|false)" . | sort -u)

if [ "$res" ]; then
echo "following packages use the inefficient assert function: please replace require.Equal/NotEqual(true, xxx) with require.True/False"
echo "$res"
exit 1
fi

exit 0
3 changes: 1 addition & 2 deletions tests/pdctl/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package store_test
import (
"context"
"encoding/json"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -101,7 +100,7 @@ func TestStore(t *testing.T) {
args = []string{"-u", pdAddr, "store", "--state", "Up,Tombstone"}
output, err = pdctl.ExecuteCommand(cmd, args...)
re.NoError(err)
re.Equal(false, strings.Contains(string(output), "\"state\":"))
re.NotContains(string(output), "\"state\":")
storesInfo = new(api.StoresInfo)
re.NoError(json.Unmarshal(output, &storesInfo))

Expand Down

0 comments on commit 29fc365

Please sign in to comment.