mirror of https://github.com/GNOME/gimp.git
app/tests: Fix warnings about files not existing
Let each test sets GIMP2_DIRECTORY on their own through the help of a new test utility function gimp_test_utils_set_gimp2_directory() that is compiled into its own lib which tests are then linked with. Also, instead of using "/tmp/gimpdir", we use "gimpdir-empty" in the source dir. This way we get rid of a bunch of annoying warnings when running the tests and have more control.
This commit is contained in:
parent
47709fab18
commit
780ebd7c24
|
@ -1,6 +1,8 @@
|
|||
# Don't mess with user's dir
|
||||
# Don't mess with user's gimpdir. Pass in the abs top srcdir to the
|
||||
# tests through an environment variable so they can set the gimpdir
|
||||
# they want to use
|
||||
TESTS_ENVIRONMENT = \
|
||||
GIMP2_DIRECTORY=$(abs_top_srcdir)/app/tests/gimpdir
|
||||
GIMP_TESTING_ABS_TOP_SRCDIR=$(abs_top_srcdir)
|
||||
|
||||
TESTS = \
|
||||
test-layer-grouping \
|
||||
|
@ -12,6 +14,11 @@ TESTS = \
|
|||
|
||||
EXTRA_PROGRAMS = $(TESTS)
|
||||
|
||||
noinst_LIBRARIES = libgimpapptestutils.a
|
||||
libgimpapptestutils_a_SOURCES = \
|
||||
gimp-app-test-utils.c \
|
||||
gimp-app-test-utils.h
|
||||
|
||||
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
|
||||
libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
|
||||
libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
|
||||
|
@ -77,6 +84,7 @@ LDADD = \
|
|||
$(top_builddir)/app/paint-funcs/libapppaint-funcs.a \
|
||||
$(top_builddir)/app/base/libappbase.a \
|
||||
$(top_builddir)/app/libapp.a \
|
||||
libgimpapptestutils.a \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimpconfig) \
|
||||
$(libgimpmath) \
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 2009 Martin Nordholts <martinn@src.gnome.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "gimp-app-test-utils.h"
|
||||
|
||||
/**
|
||||
* gimp_test_utils_set_gimp2_directory:
|
||||
* @subdir:
|
||||
*
|
||||
* Sets GIMP2_DIRECTORY to the source dir ./app/tests/@subdir. Make
|
||||
* sure to run it before using any of the GIMP functions.
|
||||
**/
|
||||
void
|
||||
gimp_test_utils_set_gimp2_directory (const gchar *subdir)
|
||||
{
|
||||
gchar *gimpdir = NULL;
|
||||
|
||||
/* GIMP_TESTING_ABS_TOP_SRCDIR is set by the automake test runner,
|
||||
* see Makefile.am
|
||||
*/
|
||||
gimpdir = g_build_filename (g_getenv ("GIMP_TESTING_ABS_TOP_SRCDIR"),
|
||||
"app/tests",
|
||||
subdir,
|
||||
NULL);
|
||||
|
||||
g_setenv ("GIMP2_DIRECTORY", gimpdir, TRUE);
|
||||
|
||||
g_free (gimpdir);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 2009 Martin Nordholts <martinn@src.gnome.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_RECTANGLE_SELECT_TOOL_H__
|
||||
#define __GIMP_RECTANGLE_SELECT_TOOL_H__
|
||||
|
||||
|
||||
void gimp_test_utils_set_gimp2_directory (const gchar *subdir);
|
||||
|
||||
|
||||
#endif /* __GIMP_RECTANGLE_SELECT_TOOL_H__ */
|
|
@ -0,0 +1,11 @@
|
|||
/colorrc
|
||||
/controllerrc
|
||||
/dockrc
|
||||
/menurc
|
||||
/parasiterc
|
||||
/pluginrc
|
||||
/sessionrc
|
||||
/templaterc
|
||||
/themerc
|
||||
/toolrc
|
||||
/unitrc
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<tags>
|
||||
|
||||
<resource identifier="gimp-brush-clipboard" checksum="157dcef48665ab465439cfaf10d6feeb">
|
||||
</resource>
|
||||
|
||||
<resource identifier="gimp-pattern-clipboard" checksum="eff9598f9f61c1dc78d842f1798c2ab8">
|
||||
</resource>
|
||||
|
||||
<resource identifier="gimp-gradient-fg-bg-rgb" checksum="12ad9439c57e897e50fb0399439e5b2b">
|
||||
</resource>
|
||||
|
||||
<resource identifier="gimp-gradient-fg-bg-hsv-cw" checksum="86589f70c8a7777c6e2d1d14b99e3759">
|
||||
</resource>
|
||||
|
||||
<resource identifier="gimp-gradient-fg-bg-hsv-ccw" checksum="65aacbbd72d99ff20ca1bd310f0a21a5">
|
||||
</resource>
|
||||
|
||||
<resource identifier="gimp-gradient-fg-bg-rgb" checksum="4a878c6cfae0b0e03c0834723daadf92">
|
||||
</resource>
|
||||
|
||||
<resource identifier="gimp-gradient-fg-transparent" checksum="1491f74caf057a39c8193470da2d2a29">
|
||||
</resource>
|
||||
</tags>
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "tests.h"
|
||||
|
||||
#include "gimp-app-test-utils.h"
|
||||
|
||||
|
||||
#define GIMP_TEST_IMAGE_SIZE 100
|
||||
|
||||
|
@ -52,9 +54,10 @@ main (int argc,
|
|||
{
|
||||
g_thread_init (NULL);
|
||||
g_type_init ();
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
gimp_test_utils_set_gimp2_directory ("gimpdir");
|
||||
|
||||
/* We share the same application instance across all tests */
|
||||
gimp = gimp_init_for_testing (TRUE);
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "tests.h"
|
||||
|
||||
#include "gimp-app-test-utils.h"
|
||||
|
||||
|
||||
#define GIMP_TEST_IMAGE_SIZE 100
|
||||
|
||||
|
@ -54,9 +56,10 @@ main (int argc,
|
|||
{
|
||||
g_thread_init (NULL);
|
||||
g_type_init ();
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
gimp_test_utils_set_gimp2_directory ("gimpdir");
|
||||
|
||||
/* We share the same application instance across all tests */
|
||||
gimp = gimp_init_for_testing (TRUE);
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
|
||||
#include "tests.h"
|
||||
|
||||
#include "gimp-app-test-utils.h"
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -63,13 +65,19 @@ int main(int argc, char **argv)
|
|||
GimpTestFileState initial_dockrc_state = { NULL, { 0, 0 } };
|
||||
GimpTestFileState final_sessionrc_state = { NULL, { 0, 0 } };
|
||||
GimpTestFileState final_dockrc_state = { NULL, { 0, 0 } };
|
||||
gchar *sessionrc_filename = gimp_personal_rc_file ("sessionrc");
|
||||
gchar *dockrc_filename = gimp_personal_rc_file ("dockrc");
|
||||
gchar *sessionrc_filename = NULL;
|
||||
gchar *dockrc_filename = NULL;
|
||||
|
||||
g_type_init ();
|
||||
gtk_init (&argc, &argv);
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
/* Make sure to run this before we use any GIMP functions */
|
||||
gimp_test_utils_set_gimp2_directory ("gimpdir");
|
||||
|
||||
sessionrc_filename = gimp_personal_rc_file ("sessionrc");
|
||||
dockrc_filename = gimp_personal_rc_file ("dockrc");
|
||||
|
||||
/* Remeber the modtimes and MD5s */
|
||||
if (!gimp_test_get_file_state_verbose (sessionrc_filename,
|
||||
&initial_sessionrc_state))
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
|
||||
#include "tests.h"
|
||||
|
||||
#include "gimp-app-test-utils.h"
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -65,6 +67,8 @@ int main(int argc, char **argv)
|
|||
gtk_init (&argc, &argv);
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
gimp_test_utils_set_gimp2_directory ("gimpdir");
|
||||
|
||||
/* Start up GIMP */
|
||||
gimp = gimp_init_for_gui_testing (FALSE, TRUE);
|
||||
gimp_test_run_mainloop_until_idle ();
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
#include "tests.h"
|
||||
|
||||
#include "gimp-app-test-utils.h"
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -49,13 +51,12 @@ int main(int argc, char **argv)
|
|||
{
|
||||
int test_result;
|
||||
|
||||
/* Disable the user dir for this test */
|
||||
g_setenv ("GIMP2_DIRECTORY", "/tmp/gimpdir", TRUE);
|
||||
|
||||
g_type_init ();
|
||||
gtk_init (&argc, &argv);
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
gimp_test_utils_set_gimp2_directory ("gimpdir-empty");
|
||||
|
||||
/* We share the same application instance across all tests */
|
||||
gimp = gimp_init_for_gui_testing (FALSE, FALSE);
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include "tests.h"
|
||||
|
||||
#include "gimp-app-test-utils.h"
|
||||
|
||||
|
||||
#define GIMP_MAINIMAGE_WIDTH 100
|
||||
#define GIMP_MAINIMAGE_HEIGHT 90
|
||||
|
@ -429,6 +431,8 @@ main (int argc,
|
|||
gtk_init (&argc, &argv);
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
gimp_test_utils_set_gimp2_directory ("gimpdir");
|
||||
|
||||
/* We share the same application instance across all tests. We need
|
||||
* the GUI variant for the file procs
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue