tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
upower: Add installed tests
Jan Tojnar
2 years ago
d08e84b3
b9c867fd
+110
-2
4 changed files
expand all
collapse all
unified
split
nixos
tests
installed-tests
default.nix
upower.nix
pkgs
os-specific
linux
upower
default.nix
installed-tests-path.patch
+1
nixos/tests/installed-tests/default.nix
reviewed
···
107
107
malcontent = callInstalledTest ./malcontent.nix {};
108
108
ostree = callInstalledTest ./ostree.nix {};
109
109
pipewire = callInstalledTest ./pipewire.nix {};
110
110
+
upower = callInstalledTest ./upower.nix {};
110
111
xdg-desktop-portal = callInstalledTest ./xdg-desktop-portal.nix {};
111
112
}
+9
nixos/tests/installed-tests/upower.nix
reviewed
···
1
1
+
{ pkgs, makeInstalledTest, ... }:
2
2
+
3
3
+
makeInstalledTest {
4
4
+
tested = pkgs.upower;
5
5
+
6
6
+
testConfig = {
7
7
+
services.upower.enable = true;
8
8
+
};
9
9
+
}
+44
-2
pkgs/os-specific/linux/upower/default.nix
reviewed
···
2
2
, stdenv
3
3
, fetchFromGitLab
4
4
, fetchpatch
5
5
+
, makeWrapper
5
6
, pkg-config
6
7
, rsync
7
8
, libxslt
···
23
24
, useIMobileDevice ? true
24
25
, libimobiledevice
25
26
, withDocs ? (stdenv.buildPlatform == stdenv.hostPlatform)
27
27
+
, nixosTests
26
28
}:
27
29
28
30
stdenv.mkDerivation (finalAttrs: {
29
31
pname = "upower";
30
32
version = "1.90.2";
31
33
32
32
-
outputs = [ "out" "dev" ]
34
34
+
outputs = [ "out" "dev" "installedTests" ]
33
35
++ lib.optionals withDocs [ "devdoc" ];
34
36
35
37
src = fetchFromGitLab {
···
44
46
# Remove when this is fixed upstream:
45
47
# https://gitlab.freedesktop.org/upower/upower/-/issues/214
46
48
./i686-test-remove-battery-check.patch
49
49
+
] ++ [
50
50
+
./installed-tests-path.patch
47
51
];
48
52
49
53
strictDeps = true;
···
61
65
gettext
62
66
gobject-introspection
63
67
libxslt
68
68
+
makeWrapper
64
69
pkg-config
65
70
rsync
66
71
];
···
72
77
systemd
73
78
# Duplicate from nativeCheckInputs until https://github.com/NixOS/nixpkgs/issues/161570 is solved
74
79
umockdev
80
80
+
81
81
+
# For installed tests.
82
82
+
(python3.withPackages (pp: [
83
83
+
pp.dbus-python
84
84
+
pp.python-dbusmock
85
85
+
pp.pygobject3
86
86
+
pp.packaging
87
87
+
]))
75
88
] ++ lib.optionals useIMobileDevice [
76
89
libimobiledevice
77
90
];
···
99
112
"-Dudevhwdbdir=${placeholder "out"}/lib/udev/hwdb.d"
100
113
"-Dintrospection=${if (stdenv.buildPlatform == stdenv.hostPlatform) then "auto" else "disabled"}"
101
114
"-Dgtk-doc=${lib.boolToString withDocs}"
115
115
+
"-Dinstalled_test_prefix=${placeholder "installedTests"}"
102
116
];
103
117
104
118
doCheck = true;
···
106
120
postPatch = ''
107
121
patchShebangs src/linux/integration-test.py
108
122
patchShebangs src/linux/unittest_inspector.py
123
123
+
124
124
+
substituteInPlace src/linux/integration-test.py \
125
125
+
--replace "/usr/share/dbus-1" "$out/share/dbus-1"
109
126
'';
110
127
111
128
preCheck = ''
···
127
144
runHook postCheck
128
145
'';
129
146
147
147
+
postCheck = ''
148
148
+
# Undo patchShebangs from postPatch so that it can be replaced with runtime shebang
149
149
+
# unittest_inspector.py intentionally not reverted because it would trigger
150
150
+
# meson rebuild during install and it is not used at runtime anyway.
151
151
+
sed -Ei 's~#!.+/bin/python3~#!/usr/bin/python3~' \
152
152
+
../src/linux/integration-test.py
153
153
+
'';
154
154
+
130
155
postInstall = ''
131
156
# Move stuff from DESTDIR to proper location.
132
157
# We use rsync to merge the directories.
···
134
159
rsync --archive "$DESTDIR/$dir" "$out"
135
160
rm --recursive "$DESTDIR/$dir"
136
161
done
137
137
-
for o in out dev; do
162
162
+
for o in out dev installedTests; do
138
163
rsync --archive "$DESTDIR/''${!o}" "$(dirname "''${!o}")"
139
164
rm --recursive "$DESTDIR/''${!o}"
140
165
done
···
142
167
rmdir "$DESTDIR/nix/store" "$DESTDIR/nix" "$DESTDIR"
143
168
'';
144
169
170
170
+
postFixup = ''
171
171
+
wrapProgram "$installedTests/libexec/upower/integration-test.py" \
172
172
+
--prefix GI_TYPELIB_PATH : "${lib.makeSearchPath "lib/girepository-1.0" [
173
173
+
"$out"
174
174
+
umockdev.out
175
175
+
]}" \
176
176
+
--prefix PATH : "${lib.makeBinPath [
177
177
+
umockdev
178
178
+
]}"
179
179
+
'';
180
180
+
145
181
env = {
146
182
# HACK: We want to install configuration files to $out/etc
147
183
# but upower should read them from /etc on a NixOS system.
···
150
186
# so we need to convince it to install all files to a temporary
151
187
# location using DESTDIR and then move it to proper one in postInstall.
152
188
DESTDIR = "${placeholder "out"}/dest";
189
189
+
};
190
190
+
191
191
+
passthru = {
192
192
+
tests = {
193
193
+
installedTests = nixosTests.installed-tests.upower;
194
194
+
};
153
195
};
154
196
155
197
meta = with lib; {
+56
pkgs/os-specific/linux/upower/installed-tests-path.patch
reviewed
···
1
1
+
diff --git a/meson_options.txt b/meson_options.txt
2
2
+
index eec3659..f064a1b 100644
3
3
+
--- a/meson_options.txt
4
4
+
+++ b/meson_options.txt
5
5
+
@@ -6,6 +6,10 @@ option('gtk-doc',
6
6
+
type : 'boolean',
7
7
+
value : 'true',
8
8
+
description : 'Build developer documentation')
9
9
+
+option('installed_test_prefix',
10
10
+
+ type: 'string',
11
11
+
+ value: '',
12
12
+
+ description: 'Prefix for installed tests')
13
13
+
option('introspection',
14
14
+
type : 'feature',
15
15
+
value : 'auto',
16
16
+
diff --git a/src/meson.build b/src/meson.build
17
17
+
index a2352ac..c1f25ac 100644
18
18
+
--- a/src/meson.build
19
19
+
+++ b/src/meson.build
20
20
+
@@ -85,6 +85,7 @@ install_subdir('does-not-exist', install_dir: historydir, strip_directory : true
21
21
+
22
22
+
cdata = configuration_data()
23
23
+
cdata.set('libexecdir', get_option('prefix') / get_option('libexecdir'))
24
24
+
+cdata.set('installed_test_bindir', get_option('installed_test_prefix') / 'libexec' / 'upower')
25
25
+
cdata.set('historydir', historydir)
26
26
+
27
27
+
configure_file(
28
28
+
@@ -147,16 +148,16 @@ if os_backend == 'linux' and gobject_introspection.found()
29
29
+
'linux/integration-test.py',
30
30
+
'linux/output_checker.py',
31
31
+
],
32
32
+
- install_dir: get_option('prefix') / get_option('libexecdir') / 'upower'
33
33
+
+ install_dir: get_option('installed_test_prefix') / 'libexec' / 'upower'
34
34
+
)
35
35
+
install_subdir('linux/tests/',
36
36
+
- install_dir: get_option('prefix') / get_option('libexecdir') / 'upower'
37
37
+
+ install_dir: get_option('installed_test_prefix') / 'libexec' / 'upower'
38
38
+
)
39
39
+
40
40
+
configure_file(
41
41
+
input: 'upower-integration.test.in',
42
42
+
output: 'upower-integration.test',
43
43
+
- install_dir: get_option('datadir') / 'installed-tests' / 'upower',
44
44
+
+ install_dir: get_option('installed_test_prefix') / 'share' / 'installed-tests' / 'upower',
45
45
+
configuration: cdata
46
46
+
)
47
47
+
endif
48
48
+
diff --git a/src/upower-integration.test.in b/src/upower-integration.test.in
49
49
+
index 151ded0..b0a9bec 100644
50
50
+
--- a/src/upower-integration.test.in
51
51
+
+++ b/src/upower-integration.test.in
52
52
+
@@ -1,3 +1,3 @@
53
53
+
[Test]
54
54
+
Type=session
55
55
+
-Exec=@libexecdir@/upower/integration-test.py
56
56
+
+Exec=@installed_test_bindir@/integration-test.py