tests: (Try to) print the actual enum value in the errors file

Instead of gtk-some-error-quark 5, print
GTK_SOME_ERROR_SOMETHING_FAILED.
This commit is contained in:
Benjamin Otte 2011-04-08 16:59:17 +02:00
parent 71b18a9006
commit be1da7ef92
3 changed files with 30 additions and 8 deletions

View File

@ -1 +1 @@
close-at-end-of-file.css:3: error: gtk-css-provider-error-quark 1
close-at-end-of-file.css:3: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

@ -1 +1 @@
does-not-exist.css:2: error: gtk-css-provider-error-quark 2
does-not-exist.css:2: error: GTK_CSS_PROVIDER_ERROR_PROPERTY_NAME

View File

@ -116,6 +116,22 @@ done:
return diff;
}
static void
append_error_value (GString *string,
GType enum_type,
guint value)
{
GEnumClass *enum_class;
GEnumValue *enum_value;
enum_class = g_type_class_ref (enum_type);
enum_value = g_enum_get_value (enum_class, value);
g_string_append (string, enum_value->value_name);
g_type_class_unref (enum_class);
}
static void
parsing_error_cb (GtkCssProvider *provider,
const gchar *path,
@ -130,14 +146,20 @@ parsing_error_cb (GtkCssProvider *provider,
g_assert (line > 0);
basename = g_path_get_basename (path);
g_string_append_printf (errors,
"%s:%u: error: %s %u\n",
basename, line,
g_quark_to_string (error->domain),
error->code);
"%s:%u: error: ",
basename, line);
g_free (basename);
if (error->domain == GTK_CSS_PROVIDER_ERROR)
append_error_value (errors, GTK_TYPE_CSS_PROVIDER_ERROR, error->code);
else
g_string_append_printf (errors,
"%s %u\n",
g_quark_to_string (error->domain),
error->code);
g_string_append_c (errors, '\n');
}
static void