summary refs log tree commit diff
diff options
context:
space:
mode:
authorWill Bush <will.g.bush@gmail.com>2022-07-31 17:55:20 -0500
committerWill Bush <will.g.bush@gmail.com>2022-07-31 17:55:20 -0500
commitec11cf53377a3d4626a29135b206641012c41cb5 (patch)
treeae099d5e1b7699c744848e651ca24e96950796e0
parent5857574d45925585baffde730369414319228a84 (diff)
downloadnixpkgs-ec11cf53377a3d4626a29135b206641012c41cb5.tar
nixpkgs-ec11cf53377a3d4626a29135b206641012c41cb5.tar.gz
nixpkgs-ec11cf53377a3d4626a29135b206641012c41cb5.tar.bz2
nixpkgs-ec11cf53377a3d4626a29135b206641012c41cb5.tar.lz
nixpkgs-ec11cf53377a3d4626a29135b206641012c41cb5.tar.xz
nixpkgs-ec11cf53377a3d4626a29135b206641012c41cb5.tar.zst
nixpkgs-ec11cf53377a3d4626a29135b206641012c41cb5.zip
json-glib: add installed tests
https://github.com/NixOS/nixpkgs/issues/34987
-rw-r--r--nixos/tests/installed-tests/default.nix1
-rw-r--r--nixos/tests/installed-tests/json-glib.nix5
-rw-r--r--pkgs/development/libraries/json-glib/0001-meson-add-options-for-tests-installation-dirs.patch51
-rw-r--r--pkgs/development/libraries/json-glib/default.nix16
4 files changed, 72 insertions, 1 deletions
diff --git a/nixos/tests/installed-tests/default.nix b/nixos/tests/installed-tests/default.nix
index b81384aa8c0..3bb678d3678 100644
--- a/nixos/tests/installed-tests/default.nix
+++ b/nixos/tests/installed-tests/default.nix
@@ -98,6 +98,7 @@ in
   gnome-photos = callInstalledTest ./gnome-photos.nix {};
   graphene = callInstalledTest ./graphene.nix {};
   gsconnect = callInstalledTest ./gsconnect.nix {};
+  json-glib = callInstalledTest ./json-glib.nix {};
   ibus = callInstalledTest ./ibus.nix {};
   libgdata = callInstalledTest ./libgdata.nix {};
   librsvg = callInstalledTest ./librsvg.nix {};
diff --git a/nixos/tests/installed-tests/json-glib.nix b/nixos/tests/installed-tests/json-glib.nix
new file mode 100644
index 00000000000..3dfd3dd0b09
--- /dev/null
+++ b/nixos/tests/installed-tests/json-glib.nix
@@ -0,0 +1,5 @@
+{ pkgs, makeInstalledTest, ... }:
+
+makeInstalledTest {
+  tested = pkgs.json-glib;
+}
diff --git a/pkgs/development/libraries/json-glib/0001-meson-add-options-for-tests-installation-dirs.patch b/pkgs/development/libraries/json-glib/0001-meson-add-options-for-tests-installation-dirs.patch
new file mode 100644
index 00000000000..8e6d345ffcc
--- /dev/null
+++ b/pkgs/development/libraries/json-glib/0001-meson-add-options-for-tests-installation-dirs.patch
@@ -0,0 +1,51 @@
+From 06418362d5a6c8bc592acb7572f4d1b48213884f Mon Sep 17 00:00:00 2001
+From: Will Bush <will.g.bush@gmail.com>
+Date: Sun, 31 Jul 2022 02:48:18 -0500
+Subject: [PATCH] meson: add options for tests installation dirs
+
+---
+ json-glib/tests/meson.build | 13 +++++++++++--
+ meson_options.txt           |  6 ++++++
+ 2 files changed, 17 insertions(+), 2 deletions(-)
+
+diff --git a/json-glib/tests/meson.build b/json-glib/tests/meson.build
+index 1eb56c8..beab6c7 100644
+--- a/json-glib/tests/meson.build
++++ b/json-glib/tests/meson.build
+@@ -21,8 +21,17 @@ test_data = [
+   'stream-load.json',
+ ]
+ 
+-installed_test_bindir = join_paths(json_libexecdir, 'installed-tests', json_api_name)
+-installed_test_datadir = join_paths(json_datadir, 'installed-tests', json_api_name)
++installed_test_suffix = join_paths('installed-tests', json_api_name)
++
++installed_test_bindir = join_paths(get_option('installed_test_bindir'), installed_test_suffix)
++if installed_test_bindir == ''
++  installed_test_bindir = join_paths(json_libexecdir, installed_test_suffix)
++endif
++
++installed_test_datadir = join_paths(get_option('installed_test_datadir'), installed_test_suffix)
++if installed_test_datadir == ''
++  installed_test_datadir = join_paths(json_datadir, installed_test_suffix)
++endif
+ 
+ install_data(test_data, install_dir: installed_test_bindir)
+ 
+diff --git a/meson_options.txt b/meson_options.txt
+index 068a03f..b3b1837 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -10,3 +10,9 @@ option('man',
+ option('tests',
+        type: 'boolean', value: true,
+        description: 'Build the tests')
++option('installed_test_datadir', type: 'string',
++       value: '',
++       description: 'Installation directory for data files in tests')
++option('installed_test_bindir', type: 'string',
++       value: '',
++       description: 'Installation directory for binary files in tests')
+-- 
+2.36.1
+
diff --git a/pkgs/development/libraries/json-glib/default.nix b/pkgs/development/libraries/json-glib/default.nix
index 1f8f4fd1acc..11aacb3e604 100644
--- a/pkgs/development/libraries/json-glib/default.nix
+++ b/pkgs/development/libraries/json-glib/default.nix
@@ -4,6 +4,7 @@
 , glib
 , meson
 , ninja
+, nixosTests
 , pkg-config
 , gettext
 , gobject-introspection
@@ -17,13 +18,18 @@ stdenv.mkDerivation rec {
   pname = "json-glib";
   version = "1.6.6";
 
-  outputs = [ "out" "dev" "devdoc" ];
+  outputs = [ "out" "dev" "devdoc" "installedTests" ];
 
   src = fetchurl {
     url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
     sha256 = "luyYvnqR9t3jNjZyDj2i/27LuQ52zKpJSX8xpoVaSQ4=";
   };
 
+  patches = [
+    # Add option for changing installation path of installed tests.
+    ./0001-meson-add-options-for-tests-installation-dirs.patch
+  ];
+
   strictDeps = true;
 
   depsBuildBuild = [
@@ -49,6 +55,10 @@ stdenv.mkDerivation rec {
     glib
   ];
 
+  mesonFlags = [
+    "-Dinstalled_test_bindir=${placeholder "installedTests"}/libexec"
+    "-Dinstalled_test_datadir=${placeholder "installedTests"}/share"
+  ];
 
   # Run-time dependency gi-docgen found: NO (tried pkgconfig and cmake)
   # it should be a build-time dep for build
@@ -73,6 +83,10 @@ stdenv.mkDerivation rec {
   '';
 
   passthru = {
+    tests = {
+      installedTests = nixosTests.installed-tests.json-glib;
+    };
+
     updateScript = gnome.updateScript {
       packageName = pname;
       versionPolicy = "odd-unstable";