Commit 4f85541c authored by jiangpeng's avatar jiangpeng Committed by vipwzw

scirpts:update autotest

parent 653223d8
......@@ -27,7 +27,7 @@ build/para.sh
build/system-test-rpc.sh
build/ci
build/autotest/*
!build/autotest/build.sh
!build/autotest/run.sh
.DS_Store
logs/
build/wallet
......
......@@ -43,23 +43,13 @@ vet:
@go vet ${PKG_LIST_VET}
autotest: ## build autotest binary
@cd build/autotest && bash ./build.sh ${CHAIN33_PATH} && cd ../../
@cd build/autotest && bash ./run.sh build && cd ../../
@if [ -n "$(dapp)" ]; then \
rm -rf build/autotest/local \
&& cp -r $(CHAIN33_PATH)/build/autotest/local $(CHAIN33_PATH)/build/autotest/*.sh build/autotest \
&& cd build/autotest && chmod -R 755 local && chmod 755 *.sh && bash ./copy-autotest.sh local \
&& cd local && bash ./local-autotest.sh $(dapp) \
&& cd ../../../; fi
cd build/autotest && bash ./run.sh local $(dapp) && cd ../../; fi
autotest_ci: autotest ## autotest ci
@rm -rf build/autotest/jerkinsci \
&& cp -r $(CHAIN33_PATH)/build/autotest/jerkinsci $(CHAIN33_PATH)/build/autotest/*.sh build/autotest/ \
cd build/autotest &&chmod -R 755 jerkinsci && chmod 755 *.sh && bash ./copy-autotest.sh jerkinsci/temp$(proj) \
&& cd jerkinsci && bash ./jerkins-ci-autotest.sh $(proj) && cd ../../../
@cd build/autotest && bash ./run.sh jerkinsci $(proj) && cd ../../
autotest_tick: autotest ## run with ticket mining
@rm -rf build/autotest/gitlabci \
&& cp -r $(CHAIN33_PATH)/build/autotest/gitlabci $(CHAIN33_PATH)/build/autotest/*.sh build/autotest/ \
&& cd build/autotest &&chmod -R 755 gitlabci && chmod 755 *.sh && bash ./copy-autotest.sh gitlabci \
&& cd gitlabci && bash ./gitlab-ci-autotest.sh build && cd ../../../
@cd build/autotest && bash ./run.sh gitlabci build && cd ../../
update: ## version 可以是git tag打的具体版本号,也可以是commit hash, 什么都不填的情况下默认从master分支拉取最新版本
@if [ -n "$(version)" ]; then \
......
#!/usr/bin/env bash
set -e
set -o pipefail
#set -o verbose
#set -o xtrace
CHAIN33_PATH=$1
sedfix=""
if [ "$(uname)" == "Darwin" ]; then
sedfix=".bak"
fi
echo "=====chain33_path: ${CHAIN33_PATH} ========"
AutoTestMain="${CHAIN33_PATH}/cmd/autotest/main.go"
ImportPlugin='"github.com/33cn/plugin/plugin"'
function build_auto_test() {
cp "${AutoTestMain}" ./
sed -i $sedfix "/^package/a import _ ${ImportPlugin}" main.go
go build -v -i -o autotest
}
function clean_auto_test() {
rm -f ../autotest/main.go
}
trap "clean_auto_test" INT TERM EXIT
build_auto_test
#!/usr/bin/env bash
set -e
set -o pipefail
#set -o verbose
#set -o xtrace
# os: ubuntu18.04 x64
sedfix=""
if [ "$(uname)" == "Darwin" ]; then
sedfix=".bak"
fi
## get chain33 path
CHAIN33_PATH=$(grep -m1 github.com/33cn/chain33 ../../go.mod | grep -o '[^ ]\+$')
CHAIN33_PATH="${CHAIN33_PATH%/}"
if [[ -d ../../${CHAIN33_PATH} ]]; then
CHAIN33_PATH=../../"$CHAIN33_PATH"
elif [[ ! -d ${CHAIN33_PATH} ]]; then
CHAIN33_PATH="${GOPATH}"/pkg/mod/github.com/33cn/chain33@"$CHAIN33_PATH"
fi
function build_auto_test() {
trap "rm -f ../autotest/main.go" INT TERM EXIT RETURN
local AutoTestMain="${CHAIN33_PATH}/cmd/autotest/main.go"
local ImportPlugin='"github.com/33cn/plugin/plugin"'
cp "${AutoTestMain}" ./
sed -i $sedfix "/^package/a import _ ${ImportPlugin}" main.go
go build -v -i -o autotest
}
function copyAutoTestConfig() {
declare -a Chain33AutoTestDirs=("${CHAIN33_PATH}/system" "../../plugin")
echo "#copy auto test config to path \"$1\""
local AutoTestConfigFile="$1/autotest.toml"
#pre config auto test
{
echo 'cliCmd="./chain33-cli"'
echo "checkTimeout=60"
} >"${AutoTestConfigFile}"
#copy all the dapp test case config file
for rootDir in "${Chain33AutoTestDirs[@]}"; do
if [[ ! -d ${rootDir} ]]; then
continue
fi
testDirArr=$(find "${rootDir}" -type d -name autotest)
for autotest in ${testDirArr}; do
dapp=$(basename "$(dirname "${autotest}")")
dappConfig=${autotest}/${dapp}.toml
#make sure dapp have auto test config
if [ -e "${dappConfig}" ]; then
cp "${dappConfig}" "$1"/
#add dapp test case config
{
echo "[[TestCaseFile]]"
echo "dapp=\"$dapp\""
echo "filename=\"$dapp.toml\""
} >>"${AutoTestConfigFile}"
fi
done
done
}
function copyChain33() {
echo "# copy chain33 bin to path \"$1\", make sure build chain33"
cp ../chain33 ../chain33-cli ../chain33.toml "$1"
cp "${CHAIN33_PATH}"/cmd/chain33/chain33.test.toml "$1"
}
function copyAll() {
dir="$1"
#check dir exist
if [[ ! -d ${dir} ]]; then
mkdir "${dir}"
fi
cp autotest "${dir}"
copyAutoTestConfig "${dir}"
copyChain33 "${dir}"
echo "# all copy have done!"
}
function main() {
if [[ $1 == "build" ]]; then #build autotest
build_auto_test
else
dir="$1"
echo "$dir"
rm -rf ../autotest/"$dir" && mkdir "$dir"
cp -r "$CHAIN33_PATH"/build/autotest/"$dir"/* ./"$dir"/ && copyAll "$dir"
chmod -R 755 "$dir" && cd "$dir" && ./autotest.sh "${@:2}" && cd ../
fi
}
main "$@"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment