mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-09-21 20:49:52 +03:00
makeHardcodeGsettingsPatch: Add simple tests
This commit is contained in:
parent
35d24b51f5
commit
98e84e79a9
@ -81,6 +81,8 @@ with pkgs;
|
|||||||
|
|
||||||
coq = callPackage ./coq {};
|
coq = callPackage ./coq {};
|
||||||
|
|
||||||
|
makeHardcodeGsettingsPatch = callPackage ./make-hardcode-gsettings-patch { };
|
||||||
|
|
||||||
makeWrapper = callPackage ./make-wrapper { };
|
makeWrapper = callPackage ./make-wrapper { };
|
||||||
makeBinaryWrapper = callPackage ./make-binary-wrapper {
|
makeBinaryWrapper = callPackage ./make-binary-wrapper {
|
||||||
makeBinaryWrapper = pkgs.makeBinaryWrapper.override {
|
makeBinaryWrapper = pkgs.makeBinaryWrapper.override {
|
||||||
|
57
pkgs/test/make-hardcode-gsettings-patch/default.nix
Normal file
57
pkgs/test/make-hardcode-gsettings-patch/default.nix
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
{ runCommandLocal
|
||||||
|
, git
|
||||||
|
, clang-tools
|
||||||
|
, makeHardcodeGsettingsPatch
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
mkTest =
|
||||||
|
{
|
||||||
|
name,
|
||||||
|
expected,
|
||||||
|
src,
|
||||||
|
schemaIdToVariableMapping,
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
patch = makeHardcodeGsettingsPatch {
|
||||||
|
inherit src schemaIdToVariableMapping;
|
||||||
|
};
|
||||||
|
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
|
||||||
|
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";
|
||||||
|
};
|
||||||
|
expected = ./fixtures/example-project-patched;
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
#include <gio/gio.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
void schema_id_literal() {
|
||||||
|
GSettings *settings;
|
||||||
|
{
|
||||||
|
g_autoptr(GSettingsSchemaSource) schema_source;
|
||||||
|
g_autoptr(GSettingsSchema) schema;
|
||||||
|
schema_source = g_settings_schema_source_new_from_directory("@EDS@", g_settings_schema_source_get_default(), TRUE, NULL);
|
||||||
|
schema = g_settings_schema_source_lookup(schema_source, "org.gnome.evolution-data-server.addressbook", FALSE);
|
||||||
|
settings = g_settings_new_full(schema, NULL, NULL);
|
||||||
|
}
|
||||||
|
g_object_unref(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SELF_UID_PATH_ID "org.gnome.evolution-data-server.addressbook"
|
||||||
|
int schema_id_from_constant() {
|
||||||
|
GSettings *settings;
|
||||||
|
{
|
||||||
|
g_autoptr(GSettingsSchemaSource) schema_source;
|
||||||
|
g_autoptr(GSettingsSchema) schema;
|
||||||
|
schema_source = g_settings_schema_source_new_from_directory("@EDS@", g_settings_schema_source_get_default(), TRUE, NULL);
|
||||||
|
schema = g_settings_schema_source_lookup(schema_source, SELF_UID_PATH_ID, FALSE);
|
||||||
|
settings = g_settings_new_full(schema, NULL, NULL);
|
||||||
|
}
|
||||||
|
g_object_unref(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
void schema_id_autoptr() {
|
||||||
|
g_autoptr(GSettings) settings = NULL;
|
||||||
|
{
|
||||||
|
g_autoptr(GSettingsSchemaSource) schema_source;
|
||||||
|
g_autoptr(GSettingsSchema) schema;
|
||||||
|
schema_source = g_settings_schema_source_new_from_directory("@EVO@", g_settings_schema_source_get_default(), TRUE, NULL);
|
||||||
|
schema = g_settings_schema_source_lookup(schema_source, "org.gnome.evolution.calendar", FALSE);
|
||||||
|
settings = g_settings_new_full(schema, NULL, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
schema_id_literal();
|
||||||
|
schema_id_from_constant();
|
||||||
|
schema_id_autoptr();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
#include <gio/gio.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
void schema_id_literal() {
|
||||||
|
GSettings *settings;
|
||||||
|
settings = g_settings_new("org.gnome.evolution-data-server.addressbook");
|
||||||
|
g_object_unref(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SELF_UID_PATH_ID "org.gnome.evolution-data-server.addressbook"
|
||||||
|
int schema_id_from_constant() {
|
||||||
|
GSettings *settings;
|
||||||
|
settings = g_settings_new(SELF_UID_PATH_ID);
|
||||||
|
g_object_unref(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
void schema_id_autoptr() {
|
||||||
|
g_autoptr(GSettings) settings = NULL;
|
||||||
|
settings = g_settings_new("org.gnome.evolution.calendar");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
schema_id_literal();
|
||||||
|
schema_id_from_constant();
|
||||||
|
schema_id_autoptr();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user