Merge "Yardstick verify job could base on the filetype to run the test"
authorRex Lee <limingjiang@huawei.com>
Sat, 30 Mar 2019 04:12:53 +0000 (04:12 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Sat, 30 Mar 2019 04:12:53 +0000 (04:12 +0000)
tools/run_tests.sh

index 49f628e..40b21ca 100755 (executable)
@@ -66,16 +66,21 @@ run_functional_test() {
     fi
 }
 
-if [[ $opts =~ "--unit" ]]; then
-    run_tests
-fi
+# get file types of the last change on git
+file_types=$(git diff-tree -r --name-only HEAD~1 HEAD | awk -F[/] '{print $NF}' | awk -F[.] 'NF>1 {print $NF}' | uniq)
 
-if [[ $opts =~ "--coverage" ]]; then
-    run_coverage
-fi
+if [[ $file_types =~ "py" ]]; then
+    if [[ $opts =~ "--unit" ]]; then
+        run_tests
+    fi
 
-if [[ $opts =~ "--functional" ]]; then
-    run_functional_test
+    if [[ $opts =~ "--coverage" ]]; then
+        run_coverage
+    fi
+
+    if [[ $opts =~ "--functional" ]]; then
+        run_functional_test
+    fi
 fi
 
 if [[ -z $opts ]]; then