diff options
author | Katharina Fey <kookie@spacekookie.de> | 2020-05-20 01:39:43 +0200 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2020-05-20 01:39:43 +0200 |
commit | 1849de11ec1e32e9eebb83f24d5339bea88b7ed7 (patch) | |
tree | 0aaf3cead09c2d55c67c6f6a86ad20af399797d8 /nixpkgs/nixos/lib | |
parent | 304c06d7a7ea3f5c84031d325ece8d38b8c1d829 (diff) | |
parent | 0f5ce2fac0c726036ca69a5524c59a49e2973dd4 (diff) |
Merge commit '0f5ce2fac0c726036ca69a5524c59a49e2973dd4'
Diffstat (limited to 'nixpkgs/nixos/lib')
-rw-r--r-- | nixpkgs/nixos/lib/test-driver/log2html.xsl | 135 | ||||
-rw-r--r-- | nixpkgs/nixos/lib/test-driver/logfile.css | 129 | ||||
-rw-r--r-- | nixpkgs/nixos/lib/test-driver/test-driver.py | 34 | ||||
-rw-r--r-- | nixpkgs/nixos/lib/test-driver/treebits.js | 30 | ||||
-rw-r--r-- | nixpkgs/nixos/lib/testing-python.nix | 24 | ||||
-rw-r--r-- | nixpkgs/nixos/lib/testing.nix | 22 | ||||
-rw-r--r-- | nixpkgs/nixos/lib/testing/jquery-ui.nix | 24 | ||||
-rw-r--r-- | nixpkgs/nixos/lib/testing/jquery.nix | 36 |
8 files changed, 12 insertions, 422 deletions
diff --git a/nixpkgs/nixos/lib/test-driver/log2html.xsl b/nixpkgs/nixos/lib/test-driver/log2html.xsl deleted file mode 100644 index 0485412b4c8..00000000000 --- a/nixpkgs/nixos/lib/test-driver/log2html.xsl +++ /dev/null @@ -1,135 +0,0 @@ -<?xml version="1.0"?> - -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - - <xsl:output method='html' encoding="UTF-8" - doctype-public="-//W3C//DTD HTML 4.01//EN" - doctype-system="http://www.w3.org/TR/html4/strict.dtd" /> - - <xsl:template match="logfile"> - <html> - <head> - <script type="text/javascript" src="jquery.min.js"></script> - <script type="text/javascript" src="jquery-ui.min.js"></script> - <script type="text/javascript" src="treebits.js" /> - <link rel="stylesheet" href="logfile.css" type="text/css" /> - <title>Log File</title> - </head> - <body> - <h1>VM build log</h1> - <p> - <a href="javascript:" class="logTreeExpandAll">Expand all</a> | - <a href="javascript:" class="logTreeCollapseAll">Collapse all</a> - </p> - <ul class='toplevel'> - <xsl:for-each select='line|nest'> - <li> - <xsl:apply-templates select='.'/> - </li> - </xsl:for-each> - </ul> - - <xsl:if test=".//*[@image]"> - <h1>Screenshots</h1> - <ul class="vmScreenshots"> - <xsl:for-each select='.//*[@image]'> - <li><a href="{@image}"><xsl:value-of select="@image" /></a></li> - </xsl:for-each> - </ul> - </xsl:if> - - </body> - </html> - </xsl:template> - - - <xsl:template match="nest"> - - <!-- The tree should be collapsed by default if all children are - unimportant or if the header is unimportant. --> - <xsl:variable name="collapsed" select="not(./head[@expanded]) and count(.//*[@error]) = 0"/> - - <xsl:variable name="style"><xsl:if test="$collapsed">display: none;</xsl:if></xsl:variable> - - <xsl:if test="line|nest"> - <a href="javascript:" class="logTreeToggle"> - <xsl:choose> - <xsl:when test="$collapsed"><xsl:text>+</xsl:text></xsl:when> - <xsl:otherwise><xsl:text>-</xsl:text></xsl:otherwise> - </xsl:choose> - </a> - <xsl:text> </xsl:text> - </xsl:if> - - <xsl:apply-templates select='head'/> - - <!-- Be careful to only generate <ul>s if there are <li>s, otherwise itβs malformed. --> - <xsl:if test="line|nest"> - - <ul class='nesting' style="{$style}"> - <xsl:for-each select='line|nest'> - - <!-- Is this the last line? If so, mark it as such so that it - can be rendered differently. --> - <xsl:variable name="class"><xsl:choose><xsl:when test="position() != last()">line</xsl:when><xsl:otherwise>lastline</xsl:otherwise></xsl:choose></xsl:variable> - - <li class='{$class}'> - <span class='lineconn' /> - <span class='linebody'> - <xsl:apply-templates select='.'/> - </span> - </li> - </xsl:for-each> - </ul> - </xsl:if> - - </xsl:template> - - - <xsl:template match="head|line"> - <code> - <xsl:if test="@error"> - <xsl:attribute name="class">errorLine</xsl:attribute> - </xsl:if> - <xsl:if test="@warning"> - <xsl:attribute name="class">warningLine</xsl:attribute> - </xsl:if> - <xsl:if test="@priority = 3"> - <xsl:attribute name="class">prio3</xsl:attribute> - </xsl:if> - - <xsl:if test="@type = 'serial'"> - <xsl:attribute name="class">serial</xsl:attribute> - </xsl:if> - - <xsl:if test="@machine"> - <xsl:choose> - <xsl:when test="@type = 'serial'"> - <span class="machine"><xsl:value-of select="@machine"/># </span> - </xsl:when> - <xsl:otherwise> - <span class="machine"><xsl:value-of select="@machine"/>: </span> - </xsl:otherwise> - </xsl:choose> - </xsl:if> - - <xsl:choose> - <xsl:when test="@image"> - <a href="{@image}"><xsl:apply-templates/></a> - </xsl:when> - <xsl:otherwise> - <xsl:apply-templates/> - </xsl:otherwise> - </xsl:choose> - </code> - </xsl:template> - - - <xsl:template match="storeref"> - <em class='storeref'> - <span class='popup'><xsl:apply-templates/></span> - <span class='elided'>/...</span><xsl:apply-templates select='name'/><xsl:apply-templates select='path'/> - </em> - </xsl:template> - -</xsl:stylesheet> diff --git a/nixpkgs/nixos/lib/test-driver/logfile.css b/nixpkgs/nixos/lib/test-driver/logfile.css deleted file mode 100644 index a54d8504a86..00000000000 --- a/nixpkgs/nixos/lib/test-driver/logfile.css +++ /dev/null @@ -1,129 +0,0 @@ -body { - font-family: sans-serif; - background: white; -} - -h1 -{ - color: #005aa0; - font-size: 180%; -} - -a { - text-decoration: none; -} - - -ul.nesting, ul.toplevel { - padding: 0; - margin: 0; -} - -ul.toplevel { - list-style-type: none; -} - -.line, .head { - padding-top: 0em; -} - -ul.nesting li.line, ul.nesting li.lastline { - position: relative; - list-style-type: none; -} - -ul.nesting li.line { - padding-left: 2.0em; -} - -ul.nesting li.lastline { - padding-left: 2.1em; /* for the 0.1em border-left in .lastline > .lineconn */ -} - -li.line { - border-left: 0.1em solid #6185a0; -} - -li.line > span.lineconn, li.lastline > span.lineconn { - position: absolute; - height: 0.65em; - left: 0em; - width: 1.5em; - border-bottom: 0.1em solid #6185a0; -} - -li.lastline > span.lineconn { - border-left: 0.1em solid #6185a0; -} - - -em.storeref { - color: #500000; - position: relative; - width: 100%; -} - -em.storeref:hover { - background-color: #eeeeee; -} - -*.popup { - display: none; -/* background: url('http://losser.st-lab.cs.uu.nl/~mbravenb/menuback.png') repeat; */ - background: #ffffcd; - border: solid #555555 1px; - position: absolute; - top: 0em; - left: 0em; - margin: 0; - padding: 0; - z-index: 100; -} - -em.storeref:hover span.popup { - display: inline; - width: 40em; -} - - -.logTreeToggle { - text-decoration: none; - font-family: monospace; - font-size: larger; -} - -.errorLine { - color: #ff0000; - font-weight: bold; -} - -.warningLine { - color: darkorange; - font-weight: bold; -} - -.prio3 { - font-style: italic; -} - -code { - white-space: pre-wrap; -} - -.serial { - color: #56115c; -} - -.machine { - color: #002399; - font-style: italic; -} - -ul.vmScreenshots { - padding-left: 1em; -} - -ul.vmScreenshots li { - font-family: monospace; - list-style: square; -} diff --git a/nixpkgs/nixos/lib/test-driver/test-driver.py b/nixpkgs/nixos/lib/test-driver/test-driver.py index 07f27515990..bf46d0df97f 100644 --- a/nixpkgs/nixos/lib/test-driver/test-driver.py +++ b/nixpkgs/nixos/lib/test-driver/test-driver.py @@ -85,8 +85,6 @@ CHAR_TO_KEY = { } # Forward references -nr_tests: int -failed_tests: list log: "Logger" machines: "List[Machine]" @@ -145,7 +143,7 @@ class Logger: self.logfile = os.environ.get("LOGFILE", "/dev/null") self.logfile_handle = codecs.open(self.logfile, "wb") self.xml = XMLGenerator(self.logfile_handle, encoding="utf-8") - self.queue: "Queue[Dict[str, str]]" = Queue(1000) + self.queue: "Queue[Dict[str, str]]" = Queue() self.xml.startDocument() self.xml.startElement("logfile", attrs={}) @@ -371,7 +369,7 @@ class Machine: q = q.replace("'", "\\'") return self.execute( ( - "su -l {} -c " + "su -l {} --shell /bin/sh -c " "$'XDG_RUNTIME_DIR=/run/user/`id -u` " "systemctl --user {}'" ).format(user, q) @@ -393,11 +391,11 @@ class Machine: def execute(self, command: str) -> Tuple[int, str]: self.connect() - out_command = "( {} ); echo '|!EOF' $?\n".format(command) + out_command = "( {} ); echo '|!=EOF' $?\n".format(command) self.shell.send(out_command.encode()) output = "" - status_code_pattern = re.compile(r"(.*)\|\!EOF\s+(\d+)") + status_code_pattern = re.compile(r"(.*)\|\!=EOF\s+(\d+)") while True: chunk = self.shell.recv(4096).decode(errors="ignore") @@ -882,33 +880,16 @@ def run_tests() -> None: if machine.is_up(): machine.execute("sync") - if nr_tests != 0: - nr_succeeded = nr_tests - len(failed_tests) - eprint("{} out of {} tests succeeded".format(nr_succeeded, nr_tests)) - if len(failed_tests) > 0: - eprint( - "The following tests have failed:\n - {}".format( - "\n - ".join(failed_tests) - ) - ) - sys.exit(1) - @contextmanager def subtest(name: str) -> Iterator[None]: - global nr_tests - global failed_tests - with log.nested(name): - nr_tests += 1 try: yield return True except Exception as e: - failed_tests.append( - 'Test "{}" failed with error: "{}"'.format(name, str(e)) - ) - log.log("error: {}".format(str(e))) + log.log(f'Test "{name}" failed with error: "{e}"') + raise e return False @@ -928,9 +909,6 @@ if __name__ == "__main__": ] exec("\n".join(machine_eval)) - nr_tests = 0 - failed_tests = [] - @atexit.register def clean_up() -> None: with log.nested("cleaning up"): diff --git a/nixpkgs/nixos/lib/test-driver/treebits.js b/nixpkgs/nixos/lib/test-driver/treebits.js deleted file mode 100644 index 9754093dfd0..00000000000 --- a/nixpkgs/nixos/lib/test-driver/treebits.js +++ /dev/null @@ -1,30 +0,0 @@ -$(document).ready(function() { - - /* When a toggle is clicked, show or hide the subtree. */ - $(".logTreeToggle").click(function() { - if ($(this).siblings("ul:hidden").length != 0) { - $(this).siblings("ul").show(); - $(this).text("-"); - } else { - $(this).siblings("ul").hide(); - $(this).text("+"); - } - }); - - /* Implementation of the expand all link. */ - $(".logTreeExpandAll").click(function() { - $(".logTreeToggle", $(this).parent().siblings(".toplevel")).map(function() { - $(this).siblings("ul").show(); - $(this).text("-"); - }); - }); - - /* Implementation of the collapse all link. */ - $(".logTreeCollapseAll").click(function() { - $(".logTreeToggle", $(this).parent().siblings(".toplevel")).map(function() { - $(this).siblings("ul").hide(); - $(this).text("+"); - }); - }); - -}); diff --git a/nixpkgs/nixos/lib/testing-python.nix b/nixpkgs/nixos/lib/testing-python.nix index 3891adc1043..123323711a7 100644 --- a/nixpkgs/nixos/lib/testing-python.nix +++ b/nixpkgs/nixos/lib/testing-python.nix @@ -10,11 +10,7 @@ with import ./build-vms.nix { inherit system pkgs minimal extraConfigurations; }; with pkgs; -let - jquery-ui = callPackage ./testing/jquery-ui.nix { }; - jquery = callPackage ./testing/jquery.nix { }; - -in rec { +rec { inherit pkgs; @@ -62,25 +58,11 @@ in rec { requiredSystemFeatures = [ "kvm" "nixos-test" ]; - buildInputs = [ libxslt ]; - buildCommand = '' - mkdir -p $out/nix-support - - LOGFILE=$out/log.xml tests='exec(os.environ["testScript"])' ${driver}/bin/nixos-test-driver - - # Generate a pretty-printed log. - xsltproc --output $out/log.html ${./test-driver/log2html.xsl} $out/log.xml - ln -s ${./test-driver/logfile.css} $out/logfile.css - ln -s ${./test-driver/treebits.js} $out/treebits.js - ln -s ${jquery}/js/jquery.min.js $out/ - ln -s ${jquery}/js/jquery.js $out/ - ln -s ${jquery-ui}/js/jquery-ui.min.js $out/ - ln -s ${jquery-ui}/js/jquery-ui.js $out/ + mkdir -p $out - touch $out/nix-support/hydra-build-products - echo "report testlog $out log.html" >> $out/nix-support/hydra-build-products + LOGFILE=/dev/null tests='exec(os.environ["testScript"])' ${driver}/bin/nixos-test-driver for i in */xchg/coverage-data; do mkdir -p $out/coverage-data diff --git a/nixpkgs/nixos/lib/testing.nix b/nixpkgs/nixos/lib/testing.nix index 7d6a5c0a290..5c784c2f0ab 100644 --- a/nixpkgs/nixos/lib/testing.nix +++ b/nixpkgs/nixos/lib/testing.nix @@ -10,11 +10,7 @@ with import ./build-vms.nix { inherit system pkgs minimal extraConfigurations; }; with pkgs; -let - jquery-ui = callPackage ./testing/jquery-ui.nix { }; - jquery = callPackage ./testing/jquery.nix { }; - -in rec { +rec { inherit pkgs; @@ -58,23 +54,11 @@ in rec { requiredSystemFeatures = [ "kvm" "nixos-test" ]; - buildInputs = [ libxslt ]; - buildCommand = '' - mkdir -p $out/nix-support - - LOGFILE=$out/log.xml tests='eval $ENV{testScript}; die $@ if $@;' ${driver}/bin/nixos-test-driver - - # Generate a pretty-printed log. - xsltproc --output $out/log.html ${./test-driver/log2html.xsl} $out/log.xml - ln -s ${./test-driver/logfile.css} $out/logfile.css - ln -s ${./test-driver/treebits.js} $out/treebits.js - ln -s ${jquery}/js/jquery.min.js $out/ - ln -s ${jquery-ui}/js/jquery-ui.min.js $out/ + mkdir -p $out - touch $out/nix-support/hydra-build-products - echo "report testlog $out log.html" >> $out/nix-support/hydra-build-products + LOGFILE=/dev/null tests='eval $ENV{testScript}; die $@ if $@;' ${driver}/bin/nixos-test-driver for i in */xchg/coverage-data; do mkdir -p $out/coverage-data diff --git a/nixpkgs/nixos/lib/testing/jquery-ui.nix b/nixpkgs/nixos/lib/testing/jquery-ui.nix deleted file mode 100644 index 05bd8dc2f94..00000000000 --- a/nixpkgs/nixos/lib/testing/jquery-ui.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ stdenv, fetchurl, unzip }: - -stdenv.mkDerivation rec { - name = "jquery-ui-1.11.4"; - - src = fetchurl { - url = "https://jqueryui.com/resources/download/${name}.zip"; - sha256 = "0ciyaj1acg08g8hpzqx6whayq206fvf4whksz2pjgxlv207lqgjh"; - }; - - buildInputs = [ unzip ]; - - installPhase = - '' - mkdir -p "$out/js" - cp -rv . "$out/js" - ''; - - meta = { - homepage = "https://jqueryui.com/"; - description = "A library of JavaScript widgets and effects"; - platforms = stdenv.lib.platforms.all; - }; -} diff --git a/nixpkgs/nixos/lib/testing/jquery.nix b/nixpkgs/nixos/lib/testing/jquery.nix deleted file mode 100644 index 732fdb3ba87..00000000000 --- a/nixpkgs/nixos/lib/testing/jquery.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ stdenv, fetchurl, compressed ? true }: - -with stdenv.lib; - -stdenv.mkDerivation rec { - name = "jquery-1.11.3"; - - src = if compressed then - fetchurl { - url = "http://code.jquery.com/${name}.min.js"; - sha256 = "1f4glgxxn3jnvry3dpzmazj3207baacnap5w20gr2xlk789idfgc"; - } - else - fetchurl { - url = "http://code.jquery.com/${name}.js"; - sha256 = "1v956yf5spw0156rni5z77hzqwmby7ajwdcd6mkhb6zvl36awr90"; - }; - - dontUnpack = true; - - installPhase = - '' - mkdir -p "$out/js" - cp -v "$src" "$out/js/jquery.js" - ${optionalString compressed '' - (cd "$out/js" && ln -s jquery.js jquery.min.js) - ''} - ''; - - meta = with stdenv.lib; { - description = "JavaScript library designed to simplify the client-side scripting of HTML"; - homepage = "http://jquery.com/"; - license = licenses.mit; - platforms = platforms.all; - }; -} |