pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / test / make-hardcode-gsettings-patch / default.nix
blobe27a6f1792085778a4b9af1783ef74da9871da52
1 { runCommandLocal
2 , lib
3 , git
4 , clang-tools
5 , makeHardcodeGsettingsPatch
6 }:
8 let
9   mkTest =
10     {
11       name,
12       expected,
13       src,
14       patches ? [ ],
15       schemaIdToVariableMapping,
16     }:
18     let
19       patch = makeHardcodeGsettingsPatch ({
20         inherit src schemaIdToVariableMapping;
21         inherit patches;
22       });
23     in
24     runCommandLocal
25       "makeHardcodeGsettingsPatch-tests-${name}"
27       {
28         nativeBuildInputs = [
29           git
30           clang-tools
31         ];
32       }
34       ''
35         cp -r --no-preserve=all "${src}" src
36         cp -r --no-preserve=all "${expected}" src-expected
38         pushd src
39         for patch in ${lib.escapeShellArgs (builtins.map (p: "${p}") patches)}; do
40             patch < "$patch"
41         done
42         patch < "${patch}"
43         popd
45         find src -name '*.c' -print0 | while read -d $'\0' sourceFile; do
46           sourceFile=''${sourceFile#src/}
47           clang-format -style='{BasedOnStyle: InheritParentConfig, ColumnLimit: 240}' -i "src/$sourceFile" "src-expected/$sourceFile"
48           git diff --no-index "src/$sourceFile" "src-expected/$sourceFile" | cat
49         done
50         touch "$out"
51       '';
54   basic = mkTest {
55     name = "basic";
56     src = ./fixtures/example-project;
57     schemaIdToVariableMapping = {
58       "org.gnome.evolution-data-server.addressbook" = "EDS";
59       "org.gnome.evolution.calendar" = "EVO";
60       "org.gnome.seahorse.nautilus.window" = "SEANAUT";
61     };
62     expected = ./fixtures/example-project-patched;
63   };
65   patches = mkTest {
66     name = "patches";
67     src = ./fixtures/example-project-wrapped-settings-constructor;
68     patches = [
69       # Avoid using wrapper function, which the generator cannot handle.
70       ./fixtures/example-project-wrapped-settings-constructor-resolve.patch
71     ];
72     schemaIdToVariableMapping = {
73       "org.gnome.evolution-data-server.addressbook" = "EDS";
74     };
75     expected = ./fixtures/example-project-wrapped-settings-constructor-patched;
76   };