···55, ant
66, jre
77, makeWrapper
88-, runCommand
88+, testVersion
99, key
1010}:
1111···5151 --add-flags "-cp $out/share/java/KeY.jar de.uka.ilkd.key.core.Main"
5252 '';
53535454- passthru.tests.check-version = runCommand "key-help" {} ''
5555- ${key}/bin/KeY --help | grep 2.5 # Wrong version in the code. On next version change to ${version}
5656- touch $out
5757- '';
5454+ passthru.tests.version =
5555+ testVersion {
5656+ package = key;
5757+ command = "KeY --help";
5858+ # Wrong '2.5' version in the code. On next version change to ${version}
5959+ version = "2.5";
6060+ };
58615962 meta = with lib; {
6063 description = "Java formal verification tool";
+33
pkgs/build-support/trivial-builders.nix
···541541 phases = "unpackPhase patchPhase installPhase";
542542 installPhase = "cp -R ./ $out";
543543 };
544544+545545+ /* Checks the command output contains the specified version
546546+ *
547547+ * Although simplistic, this test assures that the main program
548548+ * can run. While there's no substitute for a real test case,
549549+ * it does catch dynamic linking errors and such. It also provides
550550+ * some protection against accidentally building the wrong version,
551551+ * for example when using an 'old' hash in a fixed-output derivation.
552552+ *
553553+ * Examples:
554554+ *
555555+ * passthru.tests.version = testVersion { package = hello; };
556556+ *
557557+ * passthru.tests.version = testVersion {
558558+ * package = seaweedfs;
559559+ * command = "weed version";
560560+ * };
561561+ *
562562+ * passthru.tests.version = testVersion {
563563+ * package = key;
564564+ * command = "KeY --help";
565565+ * # Wrong '2.5' version in the code. Drop on next version.
566566+ * version = "2.5";
567567+ * };
568568+ */
569569+ testVersion =
570570+ { package,
571571+ command ? "${package.meta.mainProgram or package.pname or package.name} --version",
572572+ version ? package.version,
573573+ }: runCommand "test-version" { nativeBuildInputs = [ package ]; meta.timeout = 60; } ''
574574+ ${command} | grep -Fw ${version}
575575+ touch $out
576576+ '';
544577}