diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-12-27 17:21:50 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-12-27 17:26:45 -0500 |
commit | c4ca671a9ee9f230837476e539ba7c737b3fcfb9 (patch) | |
tree | bcb398f473ef59b0182a14fb1f9989271a2bf036 | |
parent | 8bfbb2c103907e6b608969aa9002199769cc95a8 (diff) | |
download | gtk+-c4ca671a9ee9f230837476e539ba7c737b3fcfb9.tar.gz |
test-css-parser: Add a way to generate output
Use test-css-parser --generate foo.css to see the parser
output on stdout. This makes it more convenient to add new
css files to the testsuite.
-rw-r--r-- | testsuite/css/parser/test-css-parser.c | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/testsuite/css/parser/test-css-parser.c b/testsuite/css/parser/test-css-parser.c index 632fb7403b..a5bb173075 100644 --- a/testsuite/css/parser/test-css-parser.c +++ b/testsuite/css/parser/test-css-parser.c @@ -145,7 +145,7 @@ parsing_error_cb (GtkCssProvider *provider, "%s:%u: error: ", basename, gtk_css_section_get_end_line (section) + 1); g_free (basename); - + if (error->domain == GTK_CSS_PROVIDER_ERROR) append_error_value (errors, GTK_TYPE_CSS_PROVIDER_ERROR, error->code); else @@ -158,7 +158,7 @@ parsing_error_cb (GtkCssProvider *provider, } static void -test_css_file (GFile *file) +parse_css_file (GFile *file, gboolean generate) { GtkCssProvider *provider; char *css, *diff; @@ -174,12 +174,16 @@ test_css_file (GFile *file) "parsing-error", G_CALLBACK (parsing_error_cb), errors); - gtk_css_provider_load_from_path (provider, - css_file, - NULL); + gtk_css_provider_load_from_path (provider, css_file, NULL); css = gtk_css_provider_to_string (provider); + if (generate) + { + g_print ("%s", css); + goto out; + } + reference_file = test_get_reference_file (css_file); diff = diff_with_file (reference_file, css, -1, &error); @@ -190,8 +194,6 @@ test_css_file (GFile *file) g_test_message ("Resulting CSS doesn't match reference:\n%s", diff); g_test_fail (); } - - g_free (css); g_free (reference_file); errors_file = test_get_errors_file (css_file); @@ -217,7 +219,16 @@ test_css_file (GFile *file) g_string_free (errors, TRUE); g_free (diff); + +out: g_free (css_file); + g_free (css); +} + +static void +test_css_file (GFile *file) +{ + parse_css_file (file, FALSE); } static void @@ -311,6 +322,17 @@ main (int argc, char **argv) g_object_unref (dir); } + else if (strcmp (argv[1], "--generate") == 0) + { + if (argc >= 3) + { + GFile *file = g_file_new_for_commandline_arg (argv[2]); + + parse_css_file (file, TRUE); + + g_object_unref (file); + } + } else { guint i; |