Przeglądaj źródła

Merge 7ef9b909dc7efc89fe59bd78e3f875548726c2d0 into 5a5202eaca0cbf289215e1e0e40e8426ee128ee3

Harikrushna V 6 lat temu
rodzic
commit
b97c43ffee
Brak konta powiązanego z e-mailem autora
1 zmienionych plików z 17 dodań i 7 usunięć
  1. 17
    7
      scripts/insert-ignores.sh

+ 17
- 7
scripts/insert-ignores.sh Wyświetl plik

@@ -4,12 +4,22 @@ for file in `find . -name "*Test.java"`; do
4 4
   tempfile="/tmp/insert-ignores.tmp"
5 5
 
6 6
   echo -e "\n\n\n*** $file ******************************"
7
-  cat $file | \
8
-  sed 's/import org.junit.Test;/import org.junit.Test;\
9
-import org.junit.Ignore;/' | \
10
-  sed 's/@Test/@Ignore\
11
-    @Test/' | \
12
-  sed '1,/@Ignore/s/.*@Ignore//' > "$tempfile" \
13
-  && mv "$tempfile" "$file"
7
+
8
+#ignoreFound variable will check if already Ignore is imported or not.
9
+ignoreFound=`grep -q 'import org.junit.Ignore;' $file ; echo $?` > /dev/null
10
+
11
+#if ignore is not imported then add line for import
12
+if [ $ignoreFound -ne 0 ]
13
+then
14
+  cat $file | sed 's/import org.junit.Test;/import org.junit.Test;\
15
+import org.junit.Ignore;/' >  $tempfile
16
+  mv "$tempfile" "$file"
17
+  pwd
18
+fi
19
+
20
+# This AWK code will check for missing Ignore with the @Test and add it
21
+
22
+  awk 'BEGIN{igonreset=0;firsttest=1}{if($0~/.*@Ignore.*/){igonreset=1}if($0 ~ /^.*@Test/){if(igonreset!=1 && firsttest==0){print "    @Ignore(\"Remove to run test\")";}firsttest=0;igonreset=0}print $0}' $file > $tempfile
23
+  mv "$tempfile" "$file"
14 24
 done
15 25