summary refs log tree commit diff
diff options
context:
space:
mode:
authorTim Steinbach <tim@nequissimus.com>2020-11-28 13:42:00 -0500
committerTim Steinbach <tim@nequissimus.com>2020-11-28 13:42:36 -0500
commit8529788e7341cc48feee77f281a581bf34637493 (patch)
treefd5e73b6b9e2ad7fc884f706f9c0477a7653261b
parentfe8fa45573b5eff05c44d6c70976c61e4b372cdd (diff)
downloadnixpkgs-8529788e7341cc48feee77f281a581bf34637493.tar
nixpkgs-8529788e7341cc48feee77f281a581bf34637493.tar.gz
nixpkgs-8529788e7341cc48feee77f281a581bf34637493.tar.bz2
nixpkgs-8529788e7341cc48feee77f281a581bf34637493.tar.lz
nixpkgs-8529788e7341cc48feee77f281a581bf34637493.tar.xz
nixpkgs-8529788e7341cc48feee77f281a581bf34637493.tar.zst
nixpkgs-8529788e7341cc48feee77f281a581bf34637493.zip
jq: Add test
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/jq.nix10
-rw-r--r--pkgs/development/tools/jq/default.nix20
3 files changed, 22 insertions, 9 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 8cb27074f38..d746105ea64 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -172,6 +172,7 @@ in
   jenkins = handleTest ./jenkins.nix {};
   jirafeau = handleTest ./jirafeau.nix {};
   jitsi-meet = handleTest ./jitsi-meet.nix {};
+  jq = handleTest ./jq.nix {};
   k3s = handleTest ./k3s.nix {};
   kafka = handleTest ./kafka.nix {};
   keepalived = handleTest ./keepalived.nix {};
diff --git a/nixos/tests/jq.nix b/nixos/tests/jq.nix
new file mode 100644
index 00000000000..20b67522ee6
--- /dev/null
+++ b/nixos/tests/jq.nix
@@ -0,0 +1,10 @@
+import ./make-test-python.nix ({ pkgs, ... }: {
+  name = "jq";
+  meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ nequissimus ]; };
+
+  nodes.jq = { pkgs, ... }: { environment.systemPackages = [ pkgs.jq ]; };
+
+  testScript = ''
+    assert "world" in jq.succeed('echo \'{"values":["hello","world"]}\'| jq \'.values[1]\''')
+  '';
+})
diff --git a/pkgs/development/tools/jq/default.nix b/pkgs/development/tools/jq/default.nix
index 8605ef398a1..63c7e01a4b8 100644
--- a/pkgs/development/tools/jq/default.nix
+++ b/pkgs/development/tools/jq/default.nix
@@ -1,26 +1,26 @@
-{ stdenv, fetchurl, oniguruma }:
+{ stdenv, nixosTests, fetchurl, oniguruma }:
 
 stdenv.mkDerivation rec {
   pname = "jq";
-  version="1.6";
+  version = "1.6";
 
   src = fetchurl {
-    url="https://github.com/stedolan/jq/releases/download/jq-${version}/jq-${version}.tar.gz";
-    sha256="0wmapfskhzfwranf6515nzmm84r7kwljgfs7dg6bjgxakbicis2x";
+    url =
+      "https://github.com/stedolan/jq/releases/download/jq-${version}/jq-${version}.tar.gz";
+    sha256 = "0wmapfskhzfwranf6515nzmm84r7kwljgfs7dg6bjgxakbicis2x";
   };
 
   outputs = [ "bin" "doc" "man" "dev" "lib" "out" ];
 
   buildInputs = [ oniguruma ];
 
-  configureFlags =
-    [
+  configureFlags = [
     "--bindir=\${bin}/bin"
     "--sbindir=\${bin}/bin"
     "--datadir=\${doc}/share"
     "--mandir=\${man}/share/man"
-    ]
-    # jq is linked to libjq:
+  ]
+  # jq is linked to libjq:
     ++ stdenv.lib.optional (!stdenv.isDarwin) "LDFLAGS=-Wl,-rpath,\\\${libdir}";
 
   doInstallCheck = true;
@@ -30,8 +30,10 @@ stdenv.mkDerivation rec {
     $bin/bin/jq --help >/dev/null
   '';
 
+  passthru.tests = { inherit (nixosTests) jq; };
+
   meta = with stdenv.lib; {
-    description = ''A lightweight and flexible command-line JSON processor'';
+    description = "A lightweight and flexible command-line JSON processor";
     license = licenses.mit;
     maintainers = with maintainers; [ raskin globin ];
     platforms = with platforms; linux ++ darwin;