Improved test widget launcher script 39/17239/3
authorRomain Forlot <romain.forlot@iot.bzh>
Mon, 15 Oct 2018 16:14:29 +0000 (18:14 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Tue, 16 Oct 2018 10:55:44 +0000 (12:55 +0200)
Improved test widget launcher script which calls verb
synchronously and therefore we can correctly detect the end
of the test session and exit.

Bug-AGL: SPEC-1821

Change-Id: I76b777770403ad9afcc72faeeb50188f52fe1223
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
test-widget/launcher.sh.in

index 005c433..7414a7b 100644 (file)
@@ -34,27 +34,17 @@ declare -a testVerb
 
 if [[ $(jq '.testVerb|type' $CFGFILE) == "array" ]]
 then
-       testVerbLength=$(jq '.testVerb | length')
-       for (( idx=0; idx<testVerbLength; idx++ )) do
-               testVerb[$idx]=$(jq -r ".testVerb[$idx].uid" ${CFGFILE})
-       done
+        testVerbLength=$(jq '.testVerb | length')
+        for (( idx=0; idx<testVerbLength; idx++ )) do
+                testVerb[$idx]=$(jq -r ".testVerb[$idx].uid" ${CFGFILE})
+        done
 else
-       testVerb[0]=$(jq -r ".testVerb.uid" ${CFGFILE})
+        testVerb[0]=$(jq -r ".testVerb.uid" ${CFGFILE})
 fi
 
-tail -f  $AFBCLIENTIN | afb-client-demo ws://localhost:${PORT}/api?token=${TOKEN} > $AFBCLIENTOUT 2>&1 &
-CLIENTPID=$!
-
 testVerbLength=${#testVerb[@]}
 for (( idx=0; idx<testVerbLength; idx++ )) do
-       echo "$API ${testVerb[$idx]}" > $AFBCLIENTIN
+        afb-client-demo -s ws://localhost:${PORT}/api?token=${TOKEN} "$API" "${testVerb[$idx]}"
 done
 
-while read -r line
-do
-       [ "$(echo "${line}" | grep -E 'Ran [[:digit:]]+ tests in')" ] && break
-done < $AFBCLIENTOUT
-
-rm -f $AFBCLIENTIN
-rm -f $AFBCLIENTOUT
-kill $CLIENTPID
+afb-client-demo ws://localhost:${PORT}/api?token=${TOKEN} "$API" "exit"