lcov-report/README                   |   34 +++++---
 lcov-report/lcov-report.cmds.example |    8 -
 lcov-report/lcov-report.sh           |  146 +++++++++++++++++++++++------------
 3 files changed, 118 insertions(+), 70 deletions(-)

New commits:
commit ca5fa90a3cbdbdafa231c22fe6bb7f8a9e686a2d
Author: Maarten Hoes <hoes.maar...@gmail.com>
Date:   Thu Nov 13 21:51:45 2014 +0100

    Removed concept of 'commandfile', allow for seperate runs of [-b|-a|-c].
    
    Change-Id: I82721911ac808baaacbaa773a9b63e832de08c72
    Reviewed-on: https://gerrit.libreoffice.org/12413
    Reviewed-by: Norbert Thiebaud <nthieb...@gmail.com>
    Tested-by: Norbert Thiebaud <nthieb...@gmail.com>

diff --git a/lcov-report/README b/lcov-report/README
index e73f51a..542d718 100644
--- a/lcov-report/README
+++ b/lcov-report/README
@@ -1,27 +1,35 @@
 
-A small script to create gcov/lcov code coverage reports of tests run
-on the libreoffice source code.
+lcov-report.sh
 
+       A small script to create gcov/lcov code coverage reports of tests run
+       on the libreoffice source code.
 
-Usage: lcov-report.sh [-b] -c [FILE] -s [DIRECTORY] -t [DIRECTORY] -w 
[DIRECTORY]
 
+Usage: lcov-report.sh [-a|-b|-c] -s [DIRECTORY] -t [DIRECTORY] -w [DIRECTORY]
 
--s
-        Specify the location where the libreoffice source code is
-        located. This flag is mandatory.
-
--c
-        Specify the file containing the libreoffice test commands to run.
-        In it's simplest form, this file could contain a single line
-        reading something like 'cd $SRCDIR && make check'. This flag
-        is mandatory.
 
 -b
+        Run lcov commands before you run your tests. This creates a
+        baseline lcov tracefile. You can only supply one of '-a', '-b'
+        or '-c' simultaneously.
+
+-a
+        Run lcov commands after you run your tests. This creates a
+        tracefile that contains the resukts of your tests, and combines
+        it with the baseline. You can only supply one of '-a', '-b' or
+        '-c' simultaneously.
+
+-c
         Specifies to build the libreoffice sources in the location
         specified by the '-s' flag. This flag is optional. If you
         choose to omit it, you must make sure the libreoffice source
         code is built using the appropriate FLAGS ('-fprofile-arcs
-        -ftest-coverage').
+        -ftest-coverage'). You can only supply one of '-a', '-b' or
+        '-c' simultaneously.
+
+-s
+        Specify the location where the libreoffice source code is
+        located. This flag is mandatory.
 
 -t
         Specifies the directory in which to contain the lcov
diff --git a/lcov-report/lcov-report.cmds.example 
b/lcov-report/lcov-report.cmds.example
deleted file mode 100644
index a577fde..0000000
--- a/lcov-report/lcov-report.cmds.example
+++ /dev/null
@@ -1,8 +0,0 @@
-cd "$SRC_DIR"
-make check
-MY_EXITCODE=$?
-if [ "$MY_EXITCODE" != "0" ]
-then
-       echo "ERROR: make check failed with exitcode $MY_EXITCODE" >&2
-       exit "$MY_EXITCODE"
-fi
diff --git a/lcov-report/lcov-report.sh b/lcov-report/lcov-report.sh
index 607405e..c3f6420 100755
--- a/lcov-report/lcov-report.sh
+++ b/lcov-report/lcov-report.sh
@@ -15,39 +15,99 @@
 
 init()
 { 
-if [ "$SRC_DIR" = "/" -o "$TRACEFILE_DIR" = "/" -o "$HTML_DIR" = "/" ]
+if [ -n "$SOURCE_COMPILE" -a -n "$BEFORE" -o -n "$SOURCE_COMPILE" -a -n 
"$AFTER" -o -n "$BEFORE" -a -n "$AFTER" ]
 then
-       echo "ERROR: Dont use the root '/' directory for storage." >&2
+       echo "ERROR: You can only supply one of '-a', '-b' or '-c' 
simultaneously." >&2
        exit 1
 fi
 
-if [ ! -d "$SRC_DIR" ]
+if [ -n "$AFTER" -a -z "$HTML_DIR" ]
+then
+       echo "ERROR: When specifying '-a', you also need to specify '-w'." >&2
+       exit 1
+fi
+
+if [ -n "$AFTER" -a -z "$SRC_DIR" ]
 then
-       echo "ERROR: Failed to locate directory $SRC_DIR." >&2
+       echo "ERROR: When specifying '-a', you also need to specify '-s'." >&2
        exit 1
 fi
 
-rm -rf "$TRACEFILE_DIR" "$HTML_DIR"
+if [ -n "$BEFORE" -a -z "$SRC_DIR" ]
+then
+       echo "ERROR: When specifying '-b', you also need to specify '-s'." >&2
+       exit 1
+fi
 
-mkdir "$TRACEFILE_DIR"
-if [ "$?" != "0" ]
+if [ -n "$BEFORE" -o -n "$AFTER" ]
+then
+       if [ -z "$TRACEFILE_DIR" ]
+       then
+               echo "ERROR: When specifying '-a' or '-b', you also need to 
specify '-t'." >&2
+               exit 1
+       fi
+fi
+
+if [ "$SRC_DIR" = "/" -o "$TRACEFILE_DIR" = "/" -o "$HTML_DIR" = "/" ]
 then
-       echo "ERROR: Failed to create directory $TRACEFILE_DIR." >&2
+       echo "ERROR: Dont use the root '/' directory for storage." >&2
        exit 1
 fi
 
-mkdir "$HTML_DIR"
-if [ "$?" != "0" ]
+if [ ! -d "$SRC_DIR" ]
 then
-       echo "ERROR: Failed to create directory $HTML_DIR." >&2
+       echo "ERROR: Failed to locate source code directory $SRC_DIR." >&2
        exit 1
 fi
 
-if [ ! -f "$TEST_CMDS_FILE" ]
+if [ ! -d "$SRC_DIR"/.git ]
 then
-       echo "ERROR: Failed to find test command file $TEST_CMDS_FILE." >&2
+       echo "ERROR: $SRC_DIR is not a git repository." >&2
        exit 1
 fi
+
+if [ -n "$BEFORE" -a ! -d "$TRACEFILE_DIR" ]
+then
+       mkdir "$TRACEFILE_DIR"
+       if [ "$?" != "0" ]
+       then
+               echo "ERROR: Failed to create tracefile directory 
$TRACEFILE_DIR." >&2
+               exit 1
+       fi
+fi
+
+if [ -n "$BEFORE" -a -d "$TRACEFILE_DIR" ]
+then
+       rm -rf "$TRACEFILE_DIR"
+       mkdir "$TRACEFILE_DIR"
+       if [ "$?" != "0" ]
+       then
+               echo "ERROR: Failed to create tracefile directory 
$TRACEFILE_DIR." >&2
+               exit 1
+       fi
+       
+fi
+
+if [ -n "$AFTER" -a ! -d "$HTML_DIR" ]
+then
+       mkdir "$HTML_DIR"
+       if [ "$?" != "0" ]
+       then
+               echo "ERROR: Failed to create html directory $HTML_DIR." >&2
+               exit 1
+       fi
+fi
+
+if [ -n "$AFTER" -a -d "$HTML_DIR" ]
+then
+       rm -rf "$HTML_DIR"
+       mkdir "$HTML_DIR"
+       if [ "$?" != "0" ]
+       then
+               echo "ERROR: Failed to create html directory $HTML_DIR." >&2
+               exit 1
+       fi
+fi
 }
 
 lcov_cleanup()
@@ -96,18 +156,6 @@ then
 fi
 }
 
-run_tests()
-{
-/bin/sh "$TEST_CMDS_FILE"
-MY_EXITCODE=$?
-if [ "$MY_EXITCODE" != "0" ]
-then
-       echo "ERROR: failed to run tests from testfile $TEST_CMDS_FILE with 
exitcode $MY_EXITCODE." >&2
-       exit "$MY_EXITCODE"
-fi
-}
-
-
 lcov_tracefile_tests()
 {
 lcov --rc geninfo_auto_base=1 --no-external --capture --directory "$SRC_DIR" 
--output-file "$TRACEFILE_DIR"/lcov_test.info
@@ -144,11 +192,6 @@ fi
 lcov_mkhtml()
 {
 cd "$SRC_DIR"
-if [ ! -d "$SRC_DIR"/.git ]
-then
-       echo "ERROR: $SRC_DIR is not a git repository." >&2
-       exit 1
-fi
 
 COMMIT_SHA1=$(git log --date=iso | head -3 | awk '/^commit/ {print $2}')
 COMMIT_DATE=$(git log --date=iso | head -3 | awk '/^Date/ {print $2}')
@@ -173,9 +216,10 @@ fi
 
 usage()
 {
-       echo >&2 "Usage: lcov-report.sh [-b] -c [FILE] -s [DIRECTORY] -t 
[DIRECTORY] -w [DIRECTORY]
-       -b      build libreoffice sources
-       -c      file containing test commands to run
+       echo >&2 "Usage: lcov-report.sh [-a|-b|-c] -s [DIRECTORY] -t 
[DIRECTORY] -w [DIRECTORY]
+       -b      run lcov commands before your tests
+       -a      run lcov commands after your tests
+       -c      compile libreoffice sources
        -s      source code directory
        -t      tracefile directory
        -w      html (www) directory"
@@ -191,7 +235,7 @@ then
        usage
 fi
 
-while getopts ":s:t:w:c:b" opt
+while getopts ":s:t:w:abc" opt
 do
        case $opt in
                s)
@@ -203,11 +247,14 @@ do
                w)
                        export HTML_DIR="$OPTARG"
                        ;;
+               c)
+                       export SOURCE_COMPILE=TRUE
+                       ;;
                b)
-                       export SOURCE_BUILD=TRUE
+                       export BEFORE=TRUE
                        ;;
-               c)
-                       export TEST_CMDS_FILE="$OPTARG"
+               a)
+                       export AFTER=TRUE
                        ;;
                *)
                        usage
@@ -215,23 +262,24 @@ do
        esac
 done
 
-
 init
 
-lcov_cleanup
+if [ "$BEFORE" = "TRUE" ]
+then
+       lcov_cleanup
+       lcov_tracefile_baseline
+fi
 
-if [ "$SOURCE_BUILD" = "TRUE" ]
+if [ "$SOURCE_COMPILE" = "TRUE" ]
 then
        source_build
 fi
 
-lcov_tracefile_baseline
-
-run_tests
-
-lcov_tracefile_tests
-lcov_tracefile_join
-lcov_tracefile_cleanup
-
-lcov_mkhtml
+if [ "$AFTER" = "TRUE" ]
+then
+       lcov_tracefile_tests
+       lcov_tracefile_join
+       lcov_tracefile_cleanup
 
+       lcov_mkhtml
+fi
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to