check_added_ut.sh 3.2 KB
Newer Older
C
chalsliu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/bin/bash

# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
# 
# 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.

17 18
set +e
set -x
Y
YUNSHEN XIE 已提交
19
SYSTEM=`uname -s`
C
chalsliu 已提交
20 21 22 23
if [ -z ${BRANCH} ]; then
    BRANCH="develop"
fi

Y
YUNSHEN XIE 已提交
24 25 26 27 28
if [[ "$SYSTEM" == "Linux" ]] || [[ "$SYSTEM" == "Darwin" ]];then
    PADDLE_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}")/../" && pwd )"
elif [[ "$SYSTEM" == "Windows_NT" ]];then
    PADDLE_ROOT="$(cd "$PWD/../" && pwd )"
fi
C
chalsliu 已提交
29 30
CURDIR=`pwd`
cd $PADDLE_ROOT
Y
YUNSHEN XIE 已提交
31 32 33 34 35 36 37
if [[ "$SYSTEM" == "Linux" ]] || [[ "$SYSTEM" == "Darwin" ]];then
    cp $PADDLE_ROOT/paddle/scripts/paddle_build.sh $PADDLE_ROOT/paddle/scripts/paddle_build_pre.sh
elif [[ "$SYSTEM" == "Windows_NT" ]];then
    git remote | grep upstream
    if [ $? != 0 ]; then 
        git remote add upstream https://github.com/PaddlePaddle/Paddle.git
    fi
38
    git fetch upstream ${BRANCH}
Y
YUNSHEN XIE 已提交
39
fi
C
chalsliu 已提交
40
CURBRANCH=`git rev-parse --abbrev-ref HEAD`
41
echo $CURBRANCH
Y
YUNSHEN XIE 已提交
42 43 44
if [ `git branch | grep 'prec_added_ut'` ];then
    git branch -D 'prec_added_ut'
fi
C
chalsliu 已提交
45
git checkout -b prec_added_ut upstream/${BRANCH}
Y
YUNSHEN XIE 已提交
46
git branch
C
chalsliu 已提交
47 48
mkdir prec_build
cd prec_build
Y
YUNSHEN XIE 已提交
49 50 51
if [[ "$SYSTEM" == "Linux" ]] || [[ "$SYSTEM" == "Darwin" ]];then
    bash $PADDLE_ROOT/paddle/scripts/paddle_build_pre.sh cmake_gen_in_current_dir >prebuild.log 2>&1
elif [[ "$SYSTEM" == "Windows_NT" ]];then
52
    bash $PADDLE_ROOT/win_cmake.sh >prec_build.log 2>&1
Y
YUNSHEN XIE 已提交
53
fi
54 55
# remove line ended with .exe to get correct deleted_ut list
ctest -N | awk -F ':' '{print $2}' | sed '/^$/d' | sed '$d' | sed 's/ //g' | sed '/\.exe$/d' | grep 'test' > $PADDLE_ROOT/br-ut
R
risemeup1 已提交
56
#UNITTEST_DEV.spec is used for checking changes of unnitests between pr and paddle_develop in the later step
57 58
spec_path_dev=${PADDLE_ROOT}/paddle/fluid/UNITTEST_DEV.spec
ctest -N | awk -F ':' '{print $2}' | sed '/^$/d' | sed '$d' > ${spec_path_dev}
C
chalsliu 已提交
59
cd $PADDLE_ROOT/build
60 61
spec_path_pr=${PADDLE_ROOT}/paddle/fluid/UNITTEST_PR.spec
ctest -N | awk -F ':' '{print $2}' | sed '/^$/d' | sed '$d' > ${spec_path_pr}
62
ctest -N | awk -F ':' '{print $2}' | sed '/^$/d' | sed '$d' | sed 's/ //g' | sed '/\.exe$/d' | grep 'test' > $PADDLE_ROOT/pr-ut
63 64
cd $PADDLE_ROOT
grep -F -x -v -f br-ut pr-ut > $PADDLE_ROOT/added_ut
Y
YUNSHEN XIE 已提交
65 66 67
if [[ "$SYSTEM" == 'Linux' ]];then
    sort pr-ut |uniq -d > $PADDLE_ROOT/duplicate_ut
fi
C
chalsliu 已提交
68
echo "New-UT:"
69
cat $PADDLE_ROOT/added_ut
C
chalsliu 已提交
70
rm -rf prec_build
Y
YUNSHEN XIE 已提交
71 72 73
if [[ "$SYSTEM" == "Linux" ]] || [[ "$SYSTEM" == "Darwin" ]];then
    rm $PADDLE_ROOT/br-ut $PADDLE_ROOT/pr-ut $PADDLE_ROOT/paddle/scripts/paddle_build_pre.sh
elif [[ "$SYSTEM" == "Windows_NT" ]];then
74 75
    # get the deleted ut list in windows, will be used in check_change_of_unittest.sh
    grep -F -x -v -f pr-ut br-ut > $PADDLE_ROOT/deleted_ut
Z
Zhou Wei 已提交
76
    rm $PADDLE_ROOT/br-ut $PADDLE_ROOT/pr-ut $PADDLE_ROOT/win_cmake.sh
Y
YUNSHEN XIE 已提交
77 78
fi
git checkout -f $CURBRANCH
79
echo $CURBRANCH
C
chalsliu 已提交
80 81
git branch -D prec_added_ut
cd $CURDIR