check_added_ut.sh 2.9 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

24
export CI_SKIP_CPP_TEST=OFF
Y
YUNSHEN XIE 已提交
25 26 27 28 29
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 已提交
30 31
CURDIR=`pwd`
cd $PADDLE_ROOT
Y
YUNSHEN XIE 已提交
32 33 34 35 36 37 38
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
39
    git fetch upstream ${BRANCH}
Y
YUNSHEN XIE 已提交
40
fi
C
chalsliu 已提交
41
CURBRANCH=`git rev-parse --abbrev-ref HEAD`
42
echo $CURBRANCH
Y
YUNSHEN XIE 已提交
43 44 45
if [ `git branch | grep 'prec_added_ut'` ];then
    git branch -D 'prec_added_ut'
fi
C
chalsliu 已提交
46
git checkout -b prec_added_ut upstream/${BRANCH}
Y
YUNSHEN XIE 已提交
47
git branch
C
chalsliu 已提交
48 49
mkdir prec_build
cd prec_build
Y
YUNSHEN XIE 已提交
50 51 52
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
53
    bash $PADDLE_ROOT/win_cmake.sh >prec_build.log 2>&1
Y
YUNSHEN XIE 已提交
54
fi
55 56
# 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
C
chalsliu 已提交
57
cd $PADDLE_ROOT/build
58
ctest -N | awk -F ':' '{print $2}' | sed '/^$/d' | sed '$d' | sed 's/ //g' | sed '/\.exe$/d' | grep 'test' > $PADDLE_ROOT/pr-ut
59 60
cd $PADDLE_ROOT
grep -F -x -v -f br-ut pr-ut > $PADDLE_ROOT/added_ut
Y
YUNSHEN XIE 已提交
61 62 63
if [[ "$SYSTEM" == 'Linux' ]];then
    sort pr-ut |uniq -d > $PADDLE_ROOT/duplicate_ut
fi
C
chalsliu 已提交
64
echo "New-UT:"
65
cat $PADDLE_ROOT/added_ut
C
chalsliu 已提交
66
rm -rf prec_build
Y
YUNSHEN XIE 已提交
67 68 69
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
70 71
    # 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 已提交
72
    rm $PADDLE_ROOT/br-ut $PADDLE_ROOT/pr-ut $PADDLE_ROOT/win_cmake.sh
Y
YUNSHEN XIE 已提交
73 74
fi
git checkout -f $CURBRANCH
75
echo $CURBRANCH
C
chalsliu 已提交
76 77
git branch -D prec_added_ut
cd $CURDIR
78
export CI_SKIP_CPP_TEST=