[gnumeric] test: make a formal test out of the function help text sanity check.



commit d61fe8f08354ec9ea33c0f3c921261ac56eb41cb
Author: Morten Welinder <terra gnome org>
Date:   Mon Nov 2 13:26:09 2009 -0500

    test: make a formal test out of the function help text sanity check.

 plugins/sample_datasource/sample_datasource.c |   15 +++++++++++----
 src/func.c                                    |   10 +---------
 src/main-application.c                        |    7 -------
 src/sstest.c                                  |   15 +++++++++++++++
 4 files changed, 27 insertions(+), 20 deletions(-)
---
diff --git a/plugins/sample_datasource/sample_datasource.c b/plugins/sample_datasource/sample_datasource.c
index 12d4b9d..851eead 100644
--- a/plugins/sample_datasource/sample_datasource.c
+++ b/plugins/sample_datasource/sample_datasource.c
@@ -46,6 +46,7 @@
 
 GNM_PLUGIN_MODULE_HEADER;
 
+static gboolean debug;
 static int    atl_fd = -1;
 static char * atl_filename = NULL;
 static FILE  *atl_file = NULL;
@@ -145,7 +146,10 @@ go_plugin_init (GOPlugin *plugin, GOCmdContext *cc)
 	GIOChannel *channel = NULL;
 	char *filename;
 
-	g_printerr (">>>>>>>>>>>>>>>>>>>>>>>>>>>> LOAD ATL\n");
+	debug = gnm_debug_flag ("datasource");
+
+	if (debug)
+		g_printerr (">>>>>>>>>>>>>>>>>>>>>>>>>>>> LOAD ATL\n");
 	g_return_if_fail (atl_fd < 0);
 
 	filename = g_build_filename (g_get_home_dir (), "atl", NULL);
@@ -182,7 +186,8 @@ go_plugin_init (GOPlugin *plugin, GOCmdContext *cc)
 G_MODULE_EXPORT void
 go_plugin_shutdown (GOPlugin *plugin, GOCmdContext *cc)
 {
-	g_printerr ("UNLOAD ATL >>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
+	if (debug)
+		g_printerr ("UNLOAD ATL >>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
 
 	if (atl_source) {
 		g_source_remove (atl_source);
@@ -247,7 +252,8 @@ atl_last (GnmFuncEvalInfo *ei, GnmValue const * const argv[])
 static DependentFlags
 atl_last_link (GnmFuncEvalInfo *ei)
 {
-	g_printerr ("link atl_last\n");
+	if (debug)
+		g_printerr ("link atl_last\n");
 	return DEPENDENT_ALWAYS_UNLINK;
 }
 static void
@@ -263,7 +269,8 @@ atl_last_unlink (GnmFuncEvalInfo *ei)
 			g_hash_table_remove (w->value->deps, w);
 		g_free (w);
 	}
-	g_printerr ("unlink atl_last\n");
+	if (debug)
+		g_printerr ("unlink atl_last\n");
 }
 
 static GnmFuncHelp const help_atl_last[] = {
diff --git a/src/func.c b/src/func.c
index c72940e..b12545a 100644
--- a/src/func.c
+++ b/src/func.c
@@ -550,16 +550,10 @@ gnm_func_sanity_check1 (GnmFunc const *fd)
 int
 gnm_func_sanity_check (void)
 {
-	int res;
-	GOCmdContext *cc = cmd_context_stderr_new ();
+	int res = 0;
 	GPtrArray *ordered;
 	unsigned ui;
 
-	gnm_plugins_init (cc);
-	res = cmd_context_stderr_get_status (COMMAND_CONTEXT_STDERR (cc));
-	if (res)
-		goto out;
-
 	ordered = g_ptr_array_new ();
 	g_hash_table_foreach (global_symbol_table->hash,
 			      copy_hash_table_to_ptr_array, ordered);
@@ -568,7 +562,6 @@ gnm_func_sanity_check (void)
 		       ordered->len, sizeof (gpointer),
 		       func_def_cmp);
 
-	g_printerr ("Checking %d help texts...\n", (int)ordered->len);
 	for (ui = 0; ui < ordered->len; ui++) {
 		GnmFunc const *fd = g_ptr_array_index (ordered, ui);
 		if (gnm_func_sanity_check1 (fd))
@@ -577,7 +570,6 @@ gnm_func_sanity_check (void)
 
 	g_ptr_array_free (ordered, TRUE);
 
- out:
 	return res;
 }
 
diff --git a/src/main-application.c b/src/main-application.c
index a275a43..a9faf83 100644
--- a/src/main-application.c
+++ b/src/main-application.c
@@ -62,7 +62,6 @@ static gboolean split_funcdocs = FALSE;
 static gboolean immediate_exit_flag = FALSE;
 static gboolean gnumeric_no_splash = FALSE;
 static gboolean gnumeric_no_warnings = FALSE;
-static gboolean func_sanity_check = FALSE;
 static gchar  *func_def_file = NULL;
 static gchar  *func_state_file = NULL;
 static gchar  *ext_refs_file = NULL;
@@ -109,10 +108,6 @@ static const GOptionEntry gnumeric_options [] = {
 		N_("Generate new help and po files"),
 		NULL
 	},
-	{ "func-sanity-check", 0, 0, G_OPTION_ARG_NONE, &func_sanity_check,
-		N_("Sanity check functions' help texts"),
-		NULL
-	},
 	{
 		"quit", 0,
 		G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &immediate_exit_flag,
@@ -374,8 +369,6 @@ main (int argc, char const **argv)
 		return gnm_dump_func_defs (NULL, 2);
 	if (ext_refs_file)
 		return gnm_dump_func_defs (ext_refs_file, 4);
-	if (func_sanity_check)
-		return gnm_func_sanity_check ();
 
 	/* Keep in sync with .desktop file */
 	g_set_application_name (_("Gnumeric Spreadsheet"));
diff --git a/src/sstest.c b/src/sstest.c
index 1aa9047..b049bb3 100644
--- a/src/sstest.c
+++ b/src/sstest.c
@@ -193,6 +193,20 @@ test_insdel_rowcol_names (void)
 	mark_test_end (test_name);
 }
 
+static void
+test_func_help (void)
+{
+	const char *test_name = "test_insdel_rowcol_names";
+	int res;
+
+	mark_test_start (test_name);
+
+	res = gnm_func_sanity_check ();
+	g_printerr ("Result = %d\n", res);
+
+	mark_test_end (test_name);
+}
+
 #define MAYBE_DO(name) if (strcmp (testname, "all") != 0 && strcmp (testname, (name)) != 0) { } else
 
 int
@@ -243,6 +257,7 @@ main (int argc, char const **argv)
 	/* ---------------------------------------- */
 
 	MAYBE_DO ("test_insdel_rowcol_names") test_insdel_rowcol_names ();
+	MAYBE_DO ("test_func_help") test_func_help ();
 
 	/* ---------------------------------------- */
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]