2022-12-28 21:21:41 +00:00
|
|
|
{ runCommandLocal
|
2024-01-02 11:29:13 +00:00
|
|
|
, lib
|
2022-12-28 21:21:41 +00:00
|
|
|
, git
|
|
|
|
, clang-tools
|
|
|
|
, makeHardcodeGsettingsPatch
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
mkTest =
|
|
|
|
{
|
|
|
|
name,
|
|
|
|
expected,
|
|
|
|
src,
|
2024-01-02 11:29:13 +00:00
|
|
|
patches ? [ ],
|
2022-12-28 21:21:41 +00:00
|
|
|
schemaIdToVariableMapping,
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2024-01-02 11:29:13 +00:00
|
|
|
patch = makeHardcodeGsettingsPatch ({
|
2022-12-28 21:21:41 +00:00
|
|
|
inherit src schemaIdToVariableMapping;
|
2024-01-02 11:29:13 +00:00
|
|
|
inherit patches;
|
|
|
|
});
|
2022-12-28 21:21:41 +00:00
|
|
|
in
|
|
|
|
runCommandLocal
|
|
|
|
"makeHardcodeGsettingsPatch-tests-${name}"
|
|
|
|
|
|
|
|
{
|
|
|
|
nativeBuildInputs = [
|
|
|
|
git
|
|
|
|
clang-tools
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
''
|
|
|
|
cp -r --no-preserve=all "${src}" src
|
|
|
|
cp -r --no-preserve=all "${expected}" src-expected
|
|
|
|
|
|
|
|
pushd src
|
2024-01-02 11:29:13 +00:00
|
|
|
for patch in ${lib.escapeShellArgs (builtins.map (p: "${p}") patches)}; do
|
|
|
|
patch < "$patch"
|
|
|
|
done
|
2022-12-28 21:21:41 +00:00
|
|
|
patch < "${patch}"
|
|
|
|
popd
|
|
|
|
|
|
|
|
find src -name '*.c' -print0 | while read -d $'\0' sourceFile; do
|
|
|
|
sourceFile=''${sourceFile#src/}
|
|
|
|
clang-format -style='{BasedOnStyle: InheritParentConfig, ColumnLimit: 240}' -i "src/$sourceFile" "src-expected/$sourceFile"
|
|
|
|
git diff --no-index "src/$sourceFile" "src-expected/$sourceFile" | cat
|
|
|
|
done
|
|
|
|
touch "$out"
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
basic = mkTest {
|
|
|
|
name = "basic";
|
|
|
|
src = ./fixtures/example-project;
|
|
|
|
schemaIdToVariableMapping = {
|
|
|
|
"org.gnome.evolution-data-server.addressbook" = "EDS";
|
|
|
|
"org.gnome.evolution.calendar" = "EVO";
|
|
|
|
"org.gnome.seahorse.nautilus.window" = "SEANAUT";
|
|
|
|
};
|
|
|
|
expected = ./fixtures/example-project-patched;
|
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
|
|
|
|
patches = mkTest {
|
|
|
|
name = "patches";
|
|
|
|
src = ./fixtures/example-project-wrapped-settings-constructor;
|
|
|
|
patches = [
|
|
|
|
# Avoid using wrapper function, which the generator cannot handle.
|
|
|
|
./fixtures/example-project-wrapped-settings-constructor-resolve.patch
|
|
|
|
];
|
|
|
|
schemaIdToVariableMapping = {
|
|
|
|
"org.gnome.evolution-data-server.addressbook" = "EDS";
|
|
|
|
};
|
|
|
|
expected = ./fixtures/example-project-wrapped-settings-constructor-patched;
|
|
|
|
};
|
2022-12-28 21:21:41 +00:00
|
|
|
}
|