|
@@ -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
|
|