This file is indexed.

/usr/bin/dune-ctest is in libdune-common-dev 2.5.1-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
#! /usr/bin/env python3
#
# Wrapper around CTest for DUNE
#
# CTest returns with an error status not only when tests failed, but also
# when tests were only skipped.  This wrapper checks the log and returns
# successfully if no tests failed; skipped tests do not result in an error.
# This behaviour is needed in a continuous integration environment, when
# building binary packages or in other cases where the testsuite should be
# run automatically.
#
# Author: Ansgar Burchardt <Ansgar.Burchardt@tu-dresden.de>

import errno
import glob
import os.path
import shutil
import subprocess
import sys
import xml.etree.ElementTree

def printTest(test):
    status = test.get("Status")
    name = test.find("Name").text
    fullName = test.find("FullName").text
    output = test.find("Results").find("Measurement").find("Value").text

    print("======================================================================")
    print("Name:      {}".format(name))
    print("FullName:  {}".format(fullName))
    print("Status:    {}".format(status.upper()))
    if output:
        print("Output:")
        for line in output.splitlines():
            print("          ", line)
    print()

def handleTest(test):
    status = test.get("Status")
    name = test.find("Path").text
    if status == "passed":
        passed = True
    elif status == "notrun":
        printTest(test)
        passed = True
    else:
        printTest(test)
        passed = False
    return passed

def findCTestOutput():
    files = glob.glob("Testing/*/Test.xml")
    if len(files) != 1:
        fn = files.join(", ")
        raise Exception("Found multiple CTest output files: {}".format(files.join(", ")))
    return files[0]

def handleCTestOutput():
    path = findCTestOutput()
    with open(path, "r", encoding="latin-1") as fh:
        tree = xml.etree.ElementTree.parse(fh)
    root = tree.getroot()
    testing = root.find("Testing")

    passed = True
    for test in testing.findall("Test"):
        testPassed = handleTest(test)
        passed = passed and testPassed

    return passed

def runCTest(argv=[]):
    cmd = ["ctest",
           "--output-on-failure",
           "--dashboard", "ExperimentalTest",
           "--no-compress-output",
    ]
    cmd.extend(argv)
    subprocess.call(cmd)

def checkDirectory():
    if not os.path.exists("CMakeCache.txt"):
        raise Exception("ERROR: dune-ctest must be run in a cmake build directory")

def removeCTestOutput():
    try:
        shutil.rmtree("Testing")
    except OSError as e:
        if e.errno != errno.ENOENT:
            raise

def main():
    try:
        checkDirectory()
        removeCTestOutput()
        runCTest(argv=sys.argv[1:])
        passed = handleCTestOutput()
        status = 0 if passed else 1
        sys.exit(status)
    except Exception as e:
        print("Internal error: {}".format(e))
        sys.exit(127)

if __name__ == "__main__":
    main()