Browse Source

add scripts to run tests

add coverage
add coverage as dependency
(generates html report)
Stefan Schmidt 6 years ago
parent
commit
12cd9c17a3
3 changed files with 23 additions and 1 deletions
  1. 5 0
      .gitignore
  2. 17 0
      build.sh
  3. 1 1
      resources/install_dependencies.sh

+ 5 - 0
.gitignore

@@ -20,6 +20,8 @@ tures/*
 
 code/*.pcap
 code/*.xml
+code/.coverage
+code/htmlcov/
 dbs/
 *.csv
 *.stat
@@ -28,3 +30,6 @@ code_boost/src/cxx/CMakeLists.txt
 code_boost/src/cxx/cmake-build-debug/
 code_boost/src/SQLiteCpp/
 code_boost/src/cmake-build-debug/
+
+run_tests
+run_coverage

+ 17 - 0
build.sh

@@ -46,8 +46,25 @@ cd \$SCRIPT_PATH
 exec ./code/CLI.py "\$@"
 EOF
 
+# Create the test script
+cat >./run_tests  <<EOF
+#!/bin/sh
+# Find the executable
+if [ $(uname) = 'Darwin' ]; then
+    alias readlink='greadlink'
+fi
+ID2T_DIR=\$(readlink -f \$0)
+SCRIPT_PATH=\${ID2T_DIR%/*}
+cd \$SCRIPT_PATH/code
+# Execute tests
+coverage run --source=. -m unittest discover -s Test/
+coverage html
+coverage report -m
+EOF
+
 chmod +x ./code/CLI.py
 chmod +x ./id2t
+chmod +x ./run_tests
 
 echo -e "\n\nAll is set. ID2T is ready."
 echo -e "\nRun ID2T with the command './id2t'"

+ 1 - 1
resources/install_dependencies.sh

@@ -65,7 +65,7 @@ install_pkg_darwin()
 
 install_pip()
 {
-    PYTHON_MODULES="lea numpy matplotlib scapy-python3 scipy"
+    PYTHON_MODULES="lea numpy matplotlib scapy-python3 scipy coverage"
     echo -e "Python modules: Checking..."
 
     # Check first to avoid unnecessary sudo