From 9a4ed7549c5c042293f998799ecec9bd49c9b267 Mon Sep 17 00:00:00 2001 From: kezhenxu94 Date: Sun, 26 Sep 2021 07:42:20 +0800 Subject: [PATCH] Should not determine the `sed` command syntax via OS only (#38) --- test/plugin/run.sh | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/test/plugin/run.sh b/test/plugin/run.sh index 2aefd5589..0b529e873 100755 --- a/test/plugin/run.sh +++ b/test/plugin/run.sh @@ -144,18 +144,17 @@ if [[ ! -d ${agent_home} ]]; then ${mvnw} --batch-mode -f ${home}/../../pom.xml -Pagent -DskipTests clean package fi # if it fails last time, relevant information will be deleted -if [ "$os" == 'Darwin' ]; then - sed -i '' '/scenarios\/'"$scenario_name"'<\/sourceDirectory>/d' ./pom.xml -else - sed -i '/scenarios\/'"$scenario_name"'<\/sourceDirectory>/d' ./pom.xml -fi + +# MacOS sed or GNU sed +sed -i '' '/scenarios\/'"$scenario_name"'<\/sourceDirectory>/d' ./pom.xml \ +|| \ +sed -i '/scenarios\/'"$scenario_name"'<\/sourceDirectory>/d' ./pom.xml + # add scenario_name into plugin/pom.xml echo check code with the checkstyle-plugin -if [ "$os" == 'Darwin' ]; then - sed -i '' '/<\/sourceDirectories>/i\'$'\n''scenarios\/'"$scenario_name"'<\/sourceDirectory>'$'\n' ./pom.xml -else - sed -i '/<\/sourceDirectories>/i scenarios\/'"$scenario_name"'<\/sourceDirectory>' ./pom.xml -fi +sed -i '' '/<\/sourceDirectories>/i\'$'\n''scenarios\/'"$scenario_name"'<\/sourceDirectory>'$'\n' ./pom.xml \ +|| \ +sed -i '/<\/sourceDirectories>/i scenarios\/'"$scenario_name"'<\/sourceDirectory>' ./pom.xml if [[ "$force_build" == "on" ]]; then profile= @@ -163,11 +162,9 @@ if [[ "$force_build" == "on" ]]; then ${mvnw} --batch-mode -f ${home}/pom.xml clean package -DskipTests ${profile} fi # remove scenario_name into plugin/pom.xml -if [ "$os" == 'Darwin' ]; then - sed -i '' '/scenarios\/'"$scenario_name"'<\/sourceDirectory>/d' ./pom.xml -else - sed -i '/scenarios\/'"$scenario_name"'<\/sourceDirectory>/d' ./pom.xml -fi +sed -i '' '/scenarios\/'"$scenario_name"'<\/sourceDirectory>/d' ./pom.xml \ +|| \ +sed -i '/scenarios\/'"$scenario_name"'<\/sourceDirectory>/d' ./pom.xml workspace="${home}/workspace/${scenario_name}" [[ -d ${workspace} ]] && rm -rf $workspace