summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2021-10-11 18:06:04 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2021-10-13 13:01:56 +0100
commit387bc7bb7149a91fed88b01d6242816d7badccaf (patch)
tree98ae6ac7e0a18ac30ccd8ed3d3817a75f63d7326
parent8da63f16839edf12fa87af11a0730be7daf01f84 (diff)
downloadlibgweather-387bc7bb7149a91fed88b01d6242816d7badccaf.tar.gz
Move tests and tools out of the way
We should write tests and tools that look like tests in the same way we'd write code that depends on the library, instead of assuming that everything works out because it sits in the same directory.
-rw-r--r--libgweather/meson.build57
-rw-r--r--libgweather/tests/meson.build15
-rw-r--r--libgweather/tests/test_libgweather.c (renamed from libgweather/test_libgweather.c)25
-rw-r--r--libgweather/tools/meson.build40
-rw-r--r--libgweather/tools/test_locations.c (renamed from libgweather/test_locations.c)10
-rw-r--r--libgweather/tools/test_locations_utc.c (renamed from libgweather/test_locations_utc.c)12
-rw-r--r--libgweather/tools/test_metar.c (renamed from libgweather/test_metar.c)0
-rw-r--r--libgweather/tools/test_sun_moon.c (renamed from libgweather/test_sun_moon.c)0
-rw-r--r--libgweather/tools/test_weather.c (renamed from libgweather/test_weather.c)0
9 files changed, 82 insertions, 77 deletions
diff --git a/libgweather/meson.build b/libgweather/meson.build
index 0dbf41b..6851867 100644
--- a/libgweather/meson.build
+++ b/libgweather/meson.build
@@ -156,7 +156,10 @@ libgweather_static = static_library('gweather',
)
libgweather_static_dep = declare_dependency(sources: gweather_c_sources,
- include_directories: include_directories('..'),
+ include_directories: [
+ include_directories('.'),
+ include_directories('..'),
+ ],
dependencies: deps_libgweather,
link_with: libgweather_static,
)
@@ -210,53 +213,5 @@ if enable_vala
)
endif
-test_cargs = [
- '-DTEST_LOCATIONS="@0@"'.format(locations_bin.full_path()),
- '-DSCHEMASDIR="@0@/schemas"'.format(meson.source_root()),
- '-DSCHEMAS_BUILDDIR="@0@/schemas"'.format(meson.build_root()),
-]
-
-executable('test_locations',
- sources: ['test_locations.c'],
- c_args: test_cargs,
- dependencies: libgweather_static_dep,
- install: false,
-)
-
-executable('test_locations_utc',
- sources: ['test_locations_utc.c'],
- c_args: test_cargs,
- dependencies: libgweather_static_dep,
- install: false,
-)
-
-test('test_libgweather',
- executable('test_libgweather',
- sources: ['test_libgweather.c'],
- c_args: test_cargs,
- dependencies: libgweather_static_dep,
- install: false,
- ),
- depends: [locations_bin],
-)
-
-executable('test_metar',
- sources: ['test_metar.c', gweather_c_sources, gweather_priv_sources],
- c_args: test_cargs,
- dependencies: libgweather_static_dep,
- install: false,
-)
-
-executable('test_sun_moon',
- sources: ['test_sun_moon.c', 'weather-sun.c', 'weather-moon.c'],
- c_args: test_cargs,
- dependencies: libgweather_static_dep,
- install: false,
-)
-
-executable('test_weather',
- sources: ['test_weather.c'],
- c_args: test_cargs,
- dependencies: libgweather_static_dep,
- install: false,
-)
+subdir('tests')
+subdir('tools')
diff --git a/libgweather/tests/meson.build b/libgweather/tests/meson.build
new file mode 100644
index 0000000..201fd39
--- /dev/null
+++ b/libgweather/tests/meson.build
@@ -0,0 +1,15 @@
+test_cargs = [
+ '-DTEST_LOCATIONS="@0@"'.format(locations_bin.full_path()),
+ '-DSCHEMASDIR="@0@/schemas"'.format(meson.source_root()),
+ '-DSCHEMAS_BUILDDIR="@0@/schemas"'.format(meson.build_root()),
+]
+
+test('test_libgweather',
+ executable('test_libgweather',
+ sources: ['test_libgweather.c'],
+ c_args: test_cargs,
+ dependencies: libgweather_static_dep,
+ install: false,
+ ),
+ depends: [locations_bin],
+)
diff --git a/libgweather/test_libgweather.c b/libgweather/tests/test_libgweather.c
index 1a710fe..d00159d 100644
--- a/libgweather/test_libgweather.c
+++ b/libgweather/tests/test_libgweather.c
@@ -1,20 +1,7 @@
-/*
- * (c) 2017 Bastien Nocera <hadess@hadess.net>
+/* test_libgweather.c: Test suite for libgweather
*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
+ * SPDX-FileCopyrightText: 2017 Bastien Nocera <hadess@hadess.net>
+ * SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "config.h"
@@ -23,9 +10,9 @@
#include <string.h>
#include <libsoup/soup.h>
-#include <gweather-version.h>
-#include "gweather-location.h"
-#include "gweather-weather.h"
+#include <libgweather/gweather-version.h>
+
+/* We use internal API */
#include "gweather-private.h"
/* We use/test gweather_location_get_children */
diff --git a/libgweather/tools/meson.build b/libgweather/tools/meson.build
new file mode 100644
index 0000000..c1f63c6
--- /dev/null
+++ b/libgweather/tools/meson.build
@@ -0,0 +1,40 @@
+tools = [
+ {
+ 'name': 'locations',
+ },
+ {
+ 'name': 'locations_utc',
+ },
+ {
+ 'name': 'metar',
+ },
+ {
+ 'name': 'sun_moon',
+ 'sources': [
+ 'test_sun_moon.c',
+ '../weather-sun.c',
+ '../weather-moon.c',
+ ],
+ },
+ {
+ 'name': 'weather',
+ }
+]
+
+tools_cargs = [
+ '-DTEST_LOCATIONS="@0@"'.format(locations_bin.full_path()),
+ '-DSCHEMASDIR="@0@/schemas"'.format(meson.source_root()),
+ '-DSCHEMAS_BUILDDIR="@0@/schemas"'.format(meson.build_root()),
+]
+
+foreach tool: tools
+ tool_name = tool.get('name')
+ tool_sources = tool.get('sources', ['test_' + tool_name + '.c'])
+
+ executable('test_' + tool_name,
+ sources: tool_sources,
+ c_args: tools_cargs,
+ dependencies: libgweather_static_dep,
+ install: false,
+ )
+endforeach
diff --git a/libgweather/test_locations.c b/libgweather/tools/test_locations.c
index 37b333e..c930101 100644
--- a/libgweather/test_locations.c
+++ b/libgweather/tools/test_locations.c
@@ -1,7 +1,11 @@
+/* test_locations.c: Test GWeatherLocationEntry
+ *
+ * SPDX-FileCopyrightText: The GWeather authors
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
-#include <gweather-version.h>
-#include "gweather-location-entry.h"
-#include "gweather-timezone-menu.h"
+#include <gtk/gtk.h>
+#include <libgweather/gweather.h>
static void
deleted (GtkWidget *widget, GdkEvent *event, gpointer data)
diff --git a/libgweather/test_locations_utc.c b/libgweather/tools/test_locations_utc.c
index 2804448..105f1ed 100644
--- a/libgweather/test_locations_utc.c
+++ b/libgweather/tools/test_locations_utc.c
@@ -1,7 +1,11 @@
-
-#include <gweather-version.h>
-#include "gweather-location-entry.h"
-#include "gweather-timezone-menu.h"
+/* test_locations_utc.c: Test GWeatherLocationEntry with UTC time zone
+ *
+ * SPDX-FileCopyrightText: The GWeather authors
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <gtk/gtk.h>
+#include <libgweather/gweather.h>
static void
deleted (GtkWidget *widget, GdkEvent *event, gpointer data)
diff --git a/libgweather/test_metar.c b/libgweather/tools/test_metar.c
index 72a3e13..72a3e13 100644
--- a/libgweather/test_metar.c
+++ b/libgweather/tools/test_metar.c
diff --git a/libgweather/test_sun_moon.c b/libgweather/tools/test_sun_moon.c
index 6cdfb50..6cdfb50 100644
--- a/libgweather/test_sun_moon.c
+++ b/libgweather/tools/test_sun_moon.c
diff --git a/libgweather/test_weather.c b/libgweather/tools/test_weather.c
index 7773462..7773462 100644
--- a/libgweather/test_weather.c
+++ b/libgweather/tools/test_weather.c