From f21ca124a9194027fa4c807b963929818d5f06ac Mon Sep 17 00:00:00 2001
From: Jan Scotka <jscotka@redhat.com>
Date: Jul 04 2017 08:23:55 +0000
Subject: [PATCH 1/3] added possibility to generate main index.html for cumulative test results


---

diff --git a/run_mtf.sh b/run_mtf.sh
index f9cbed6..1c02244 100755
--- a/run_mtf.sh
+++ b/run_mtf.sh
@@ -19,11 +19,51 @@ MODULENAME="$1"
 MODULENAME_STREAM_VERSION="$2"
 WORKDIR="$3"
 ARTIFACTSDIR="$4"
+# Generate main index.page
+HEADER='
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<html>
+<head>
+  <title>Taskotron cumulative results for Modularity testing framework subtests</title>
+  <link href="avocado-result.modulelint/html/css/bootstrap.min.css" rel="stylesheet">
+  <link href="avocado-result.modulelint/html/css/dataTables.bootstrap.css" rel="stylesheet">
+</head>
+<body>
+<div class="container">
+  <div class="page-header">
+    <h3>Taskotron cumulative results for Modularity testing framework subtests</h3>
+  </div>
+
+  <table id="results" class="display" cellspacing="0" width="100%"><thead>
+     <tr>
+       <th>Result</th>
+       <th>Link to subtest</th>
+     </tr></thead>
+'
+FOOTER='
+  </table>
+</div>
+</body>
+</html>
+'
 
 # MTF exit codes
 MTF_EXIT_FAIL='125'
 MTF_EXIT_SKIP='126'
 
+function write_to_index {
+    local FUNC=$1
+    local TEXT=$2
+    local OUTFILE="$ARTIFACTSDIR/index.html"
+    if echo $FUNC | grep header; then
+        echo "$HEADER" > $OUTFILE
+    elif echo $FUNC | grep footer; then
+        echo "$FOOTER" >> $OUTFILE
+    elif echo $FUNC | grep body; then
+        echo "$TEXT" >> $OUTFILE
+    fi
+}
+
 function save_outcome {
     local EXITCODE="$1"
     local OUTFILE="$2"
@@ -67,6 +107,32 @@ function get_artifact {
     fi
 }
 
+function generate_html_table_row {
+    local EXITCODE="$1"
+    local URLLINK="$2"
+    local RES="PASS"
+    local RES_CLASS="success"
+    if [ "$EXITCODE" -eq 0 ]; then
+        true
+    elif [ "$EXITCODE" -eq "$MTF_EXIT_FAIL" ]; then
+        RES="FAIL"
+        RES_CLASS="danger even"
+    elif [ "$EXITCODE" -eq "$MTF_EXIT_SKIP" ]; then
+        RES="SKIP"
+        RES_CLASS="warning"
+    else
+        return 1
+    fi
+    echo "
+  <tr class='$RES_CLASS'>
+    <td>$RES</td>
+    <td><a href='$URLLINK'>$URLLINK</a></td>
+  </tr>
+"
+    return 0
+}
+
+write_to_index header
 # run module lint
 echo 'Running MTF with module lint...'
 /usr/share/moduleframework/tools/run-them.sh "$MODULENAME" "$MODULENAME_STREAM_VERSION" pdc lint
@@ -75,6 +141,7 @@ EXITCODE="$?"
 echo 'Saving module lint results...'
 save_outcome "$EXITCODE" "$WORKDIR/outcome.modulelint"
 save_artifacts "$EXITCODE" "$ARTIFACTSDIR/avocado-result.modulelint"
+write_to_index body "`generate_html_table_row $EXITCODE $ARTIFACTSDIR/avocado-result.modulelint/html/results.html`"
 
 # run module tests
 echo 'Running MTF with module tests...'
@@ -84,7 +151,9 @@ EXITCODE="$?"
 echo 'Saving module tests results...'
 save_outcome "$EXITCODE" "$WORKDIR/outcome.tests"
 save_artifacts "$EXITCODE" "$ARTIFACTSDIR/avocado-result.tests"
+write_to_index body "`generate_html_table_row $EXITCODE $ARTIFACTSDIR/avocado-result.tests/html/results.html`"
 
+write_to_index footer
 # generate overall outcome
 if grep -q FAILED "$WORKDIR"/outcome.*; then
     echo "FAILED" > "$WORKDIR/outcome.overall"
@@ -118,3 +187,4 @@ taskotron_result \
 
 # save results as an artifact, for debugging
 cp "$WORKDIR/results.yaml" "$ARTIFACTSDIR"
+

From e45d532ea8eccdedef4bae41d104e49aa705ea7a Mon Sep 17 00:00:00 2001
From: Jan Scotka <jscotka@redhat.com>
Date: Jul 04 2017 08:25:41 +0000
Subject: [PATCH 2/3] made HEADER adn FOOTER local


---

diff --git a/run_mtf.sh b/run_mtf.sh
index 1c02244..d5b3f45 100755
--- a/run_mtf.sh
+++ b/run_mtf.sh
@@ -19,8 +19,13 @@ MODULENAME="$1"
 MODULENAME_STREAM_VERSION="$2"
 WORKDIR="$3"
 ARTIFACTSDIR="$4"
-# Generate main index.page
-HEADER='
+
+# MTF exit codes
+MTF_EXIT_FAIL='125'
+MTF_EXIT_SKIP='126'
+
+function write_to_index {
+    local HEADER='
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
 <html>
 <head>
@@ -40,18 +45,12 @@ HEADER='
        <th>Link to subtest</th>
      </tr></thead>
 '
-FOOTER='
+    local FOOTER='
   </table>
 </div>
 </body>
 </html>
 '
-
-# MTF exit codes
-MTF_EXIT_FAIL='125'
-MTF_EXIT_SKIP='126'
-
-function write_to_index {
     local FUNC=$1
     local TEXT=$2
     local OUTFILE="$ARTIFACTSDIR/index.html"

From 1756a70fb19964c894aca9c8fa2f79f99f9dee91 Mon Sep 17 00:00:00 2001
From: Jan Scotka <jscotka@redhat.com>
Date: Jul 04 2017 09:52:42 +0000
Subject: [PATCH 3/3] fix class attrib for table -> colours visible


---

diff --git a/run_mtf.sh b/run_mtf.sh
index d5b3f45..6415987 100755
--- a/run_mtf.sh
+++ b/run_mtf.sh
@@ -39,7 +39,7 @@ function write_to_index {
     <h3>Taskotron cumulative results for Modularity testing framework subtests</h3>
   </div>
 
-  <table id="results" class="display" cellspacing="0" width="100%"><thead>
+  <table id="results" class="table table-striped table-bordered dataTable no-footer" cellspacing="0" width="100%"><thead>
      <tr>
        <th>Result</th>
        <th>Link to subtest</th>

