Compare commits

...

10 Commits

Author SHA1 Message Date
e08e6c6821 Fix some typos in configure.ac and .gitignore 2016-09-21 14:16:20 +02:00
f9db50919f codecov experimenting 2016-09-21 14:16:20 +02:00
617d293358 Add more tests 2016-09-21 14:16:20 +02:00
aa6a489f34 Remove invalid property testing
Execution will never arrive there, there’s no point checking it.
2016-09-21 14:16:19 +02:00
c25f650755 Add extra test to timezone changing 2016-09-21 14:16:19 +02:00
2ab696906c Add comments to tests 2016-09-21 14:16:19 +02:00
61de67efa4 Optimize coverage generating 2016-09-21 14:16:19 +02:00
e44480cb21 Clean up swe-glib.mk 2016-09-21 14:16:19 +02:00
b6d8ca18c9 Add test for bad property queries 2016-09-21 14:16:19 +02:00
132a7aaac3 Enable coverage measurement in travis 2016-09-21 14:16:19 +02:00
6 changed files with 89 additions and 54 deletions

2
.gitignore vendored
View File

@ -57,8 +57,8 @@ Makefile.in
/tests/*-test /tests/*-test
/tests/*-test.log /tests/*-test.log
/tests/*-test.trs /tests/*-test.trs
/tests/test-suite.log
/swe-glib-lcov* /swe-glib-lcov*
test-suite.log
*.gcno *.gcno
*.gcda *.gcda
*.gcov *.gcov

View File

@ -7,11 +7,13 @@ addons:
- gobject-introspection - gobject-introspection
- gnome-common - gnome-common
- autopoint - autopoint
before_script: ./autogen.sh - lcov
before_script: ./autogen.sh --enable-coverage
script: script:
- make - make
- make check - make check
before_install: before_install:
- pip install --user codecov - pip install --user codecov
after_success: after_success:
- codecov - find -type f -name '*.gcno'
- codecov --gcov-root src

View File

@ -107,7 +107,7 @@ AS_IF([ test "x$use_gcov" = "xyes"], [
AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml) AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
AS_IF([ test "$LTP" ], [ AS_IF([ test "$LTP" ], [
AC_CACHE_CHECK([for ltp version], sw_glib_cv_ltp_version, [ AC_CACHE_CHECK([for ltp version], swe_glib_cv_ltp_version, [
swe_glib_cv_ltp_version=invalid swe_glib_cv_ltp_version=invalid
ltp_version=`$LTP -v 2>/dev/null | $SED -e 's/^.* //'` ltp_version=`$LTP -v 2>/dev/null | $SED -e 's/^.* //'`
for ltp_check_version in $ltp_version_list; do for ltp_check_version in $ltp_version_list; do

View File

@ -488,10 +488,13 @@ gswe_timestamp_set_property(GObject *object,
break; break;
/* LCOV_EXCL_START Unless a property ID is missing from above,
* we will never arrive here */
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break; break;
/* LCOV_EXCL_STOP */
} }
} }
@ -585,10 +588,13 @@ gswe_timestamp_get_property(
break; break;
/* LCOV_EXCL_START Unless a property ID is missing from above,
* we will never arrive here */
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break; break;
/* LCOV_EXCL_STOP */
} }
} }

View File

@ -1,4 +1,7 @@
# SWE-GLib - GLib wrapper around the Swiss Ephemeris library # SWE-GLib - GLib wrapper around the Swiss Ephemeris library
#
# Most of this file is got from GLib, especially the code coverage measurement
# parts
GTESTER = gtester GTESTER = gtester
GTESTER_REPORT = gtester-report GTESTER_REPORT = gtester-report
@ -7,7 +10,7 @@ NULL =
# initialize variables for unconditional += appending # initialize variables for unconditional += appending
BUILT_SOURCES = BUILT_SOURCES =
BUILT_EXTRA_DIST = BUILT_EXTRA_DIST =
CLEANFILES = *.log *.trs CLEANFILES = *.log *.trs *.gcda
DISTCLEANFILES = DISTCLEANFILES =
MAINTAINERCLEANFILES = MAINTAINERCLEANFILES =
EXTRA_DIST = EXTRA_DIST =
@ -33,9 +36,7 @@ else
test-nonrecursive: test-nonrecursive:
endif endif
.PHONY: test-nonrecursive .PHONY: test-nonrecursive lcov genlcov lcov-clean
.PHONY: lcov genlcov lcov-clean
# use recursive makes in order to ignore errors during check # use recursive makes in order to ignore errors during check
lcov: lcov:
-$(MAKE) $(AM_MAKEFLAGS) -k check -$(MAKE) $(AM_MAKEFLAGS) -k check
@ -45,9 +46,8 @@ lcov:
# placing the objects files in the .libs/ directory separate from the *.c # placing the objects files in the .libs/ directory separate from the *.c
# we also have to delete tests/.libs/libmoduletestplugin_*.gcda # we also have to delete tests/.libs/libmoduletestplugin_*.gcda
genlcov: genlcov:
$(AM_V_GEN) rm -f $(top_builddir)/tests/.libs/libmoduletestplugin_*.gcda; \ $(AM_V_GEN) $(LTP) --quiet --directory $(top_builddir) --capture --output-file swe-glib-lcov.info --test-name SWE_GLIB_PERF --no-checksum --compat-libtool --ignore-errors source; \
$(LTP) --quiet --directory $(top_builddir) --capture --output-file swe-glib-lcov.info --test-name SWE_GLIB_PERF --no-checksum --compat-libtool --ignore-errors source; \ $(LTP) --quiet --output-file swe-glib-lcov.info --remove swe-glib-lcov.info docs/reference/\* /tmp/\* ; \
$(LTP) --quiet --output-file swe-glib-lcov.info --remove swe-glib-lcov.info docs/reference/\* /tmp/\* gio/tests/gdbus-object-manager-example/\* ; \
LANG=C $(LTP_GENHTML) --quiet --prefix $(top_builddir) --output-directory swe-glib-lcov --title "SWE-GLib Code Coverage" --legend --frames --show-details swe-glib-lcov.info --ignore-errors source LANG=C $(LTP_GENHTML) --quiet --prefix $(top_builddir) --output-directory swe-glib-lcov --title "SWE-GLib Code Coverage" --legend --frames --show-details swe-glib-lcov.info --ignore-errors source
@echo "file://$(abs_top_builddir)/swe-glib-lcov/index.html" @echo "file://$(abs_top_builddir)/swe-glib-lcov/index.html"
@ -59,47 +59,6 @@ lcov-clean:
# run tests in cwd as part of make check # run tests in cwd as part of make check
check-local: test-nonrecursive check-local: test-nonrecursive
# We support a fairly large range of possible variables. It is expected that all types of files in a test suite
# will belong in exactly one of the following variables.
#
# First, we support the usual automake suffixes, but in lowercase, with the customary meaning:
#
# test_programs, test_scripts, test_data, test_ltlibraries
#
# The above are used to list files that are involved in both uninstalled and installed testing. The
# test_programs and test_scripts are taken to be actual testcases and will be run as part of the test suite.
# Note that _data is always used with the nobase_ automake variable name to ensure that installed test data is
# installed in the same way as it appears in the package layout.
#
# In order to mark a particular file as being only for one type of testing, use 'installed' or 'uninstalled',
# like so:
#
# installed_test_programs, uninstalled_test_programs
# installed_test_scripts, uninstalled_test_scripts
# installed_test_data, uninstalled_test_data
# installed_test_ltlibraries, uninstalled_test_ltlibraries
#
# Additionally, we support 'extra' infixes for programs and scripts. This is used for support programs/scripts
# that should not themselves be run as testcases (but exist to be used from other testcases):
#
# test_extra_programs, installed_test_extra_programs, uninstalled_test_extra_programs
# test_extra_scripts, installed_test_extra_scripts, uninstalled_test_extra_scripts
#
# Additionally, for _scripts and _data, we support the customary dist_ prefix so that the named script or data
# file automatically end up in the tarball.
#
# dist_test_scripts, dist_test_data, dist_test_extra_scripts
# dist_installed_test_scripts, dist_installed_test_data, dist_installed_test_extra_scripts
# dist_uninstalled_test_scripts, dist_uninstalled_test_data, dist_uninstalled_test_extra_scripts
#
# Note that no file is automatically disted unless it appears in one of the dist_ variables. This follows the
# standard automake convention of not disting programs scripts or data by default.
#
# test_programs, test_scripts, uninstalled_test_programs and uninstalled_test_scripts (as well as their disted
# variants) will be run as part of the in-tree 'make check'. These are all assumed to be runnable under
# gtester. That's a bit strange for scripts, but it's possible.
# we use test -z "$(TEST_PROGS)" above, so make sure we have no extra whitespace...
TEST_PROGS += $(strip $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \ TEST_PROGS += $(strip $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
$(dist_test_scripts) $(dist_uninstalled_test_scripts)) $(dist_test_scripts) $(dist_uninstalled_test_scripts))

View File

@ -26,6 +26,7 @@ static struct testdata_t td[] = {
{ 0 } { 0 }
}; };
/* Test Gregorian date values */
static void static void
test_timestamp_gregorian(void) test_timestamp_gregorian(void)
{ {
@ -141,6 +142,7 @@ test_timestamp_gregorian(void)
g_clear_object(&timestamp); g_clear_object(&timestamp);
} }
/* Check timezone mangling */
static void static void
test_timestamp_timezone(void) test_timestamp_timezone(void)
{ {
@ -191,6 +193,7 @@ test_timestamp_timezone(void)
g_clear_object(&timestamp); g_clear_object(&timestamp);
} }
/* Test Julian Day (Ephemeris Time) properties */
static void static void
test_timestamp_jdet(void) test_timestamp_jdet(void)
{ {
@ -216,13 +219,26 @@ test_timestamp_jdet(void)
g_assert_null(err); g_assert_null(err);
gswe_assert_fuzzy_equals(jdet, td[1].jdet, 0.000001); gswe_assert_fuzzy_equals(jdet, td[1].jdet, 0.000001);
/* Set via property */
g_object_set(timestamp,
"julian-day", td[0].jdet,
NULL);
jdet = gswe_timestamp_get_julian_day_et(timestamp, &err);
gswe_assert_fuzzy_equals(jdet, td[0].jdet, 0.000001);
g_object_get(timestamp,
"julian-day", &jdet,
NULL);
gswe_assert_fuzzy_equals(jdet, td[0].jdet, 0.000001);
g_clear_object(&timestamp); g_clear_object(&timestamp);
} }
/* Test Julian Day (Universal Time) properties */
static void static void
test_timestamp_jdut(void) test_timestamp_jdut(void)
{} {}
/* Test instant-recalc property */
static void static void
test_timestamp_instant(void) test_timestamp_instant(void)
{ {
@ -268,11 +284,12 @@ test_timestamp_instant(void)
g_assert_false(jul_valid); g_assert_false(jul_valid);
} }
/* Test Gregorian Date to Julian Day conversion */
static void static void
test_timestamp_conv_gregjd(void) test_timestamp_conv_gregjd(void)
{ {
GsweTimestamp *timestamp; GsweTimestamp *timestamp;
gdouble jdet; gdouble jdet, tz_jdet;
GError *err = NULL; GError *err = NULL;
/* Create timestamp from testdata */ /* Create timestamp from testdata */
@ -293,17 +310,68 @@ test_timestamp_conv_gregjd(void)
0.0001 0.0001
); );
/* Julian Day should not change if only the timezone changes */
td[1].tz += 1.0;
tz_jdet = gswe_timestamp_get_julian_day_ut(timestamp, &err);
g_assert_cmpfloat(jdet, ==, tz_jdet);
g_clear_object(&timestamp); g_clear_object(&timestamp);
} }
/* Julian Day to Gregorian Date conversion */
static void static void
test_timestamp_conv_jdgreg(void) test_timestamp_conv_jdgreg(void)
{} {
GsweTimestamp *timestamp;
guint year, month, day, hour, minute, second, ms;
gdouble tz;
gboolean gregorian_valid, julian_valid;
GError *err = NULL;
timestamp = gswe_timestamp_new_from_julian_day(td[0].jdet);
g_assert_nonnull(timestamp);
g_object_get(timestamp,
"gregorian-valid", &gregorian_valid,
"julian-day-valid", &julian_valid,
"gregorian-timezone-offset", &tz,
NULL);
g_assert_true(julian_valid);
g_assert_cmpfloat(0.0, ==, tz);
gswe_timestamp_set_gregorian_timezone(timestamp, td[0].tz, &err);
g_object_get(
timestamp,
"gregorian-year", &year,
"gregorian-month", &month,
"gregorian-day", &day,
"gregorian-hour", &hour,
"gregorian-minute", &minute,
"gregorian-second", &second,
"gregorian-microsecond", &ms,
"gregorian-timezone-offset", &tz,
NULL
);
g_assert_cmpint(year, ==, td[0].year);
g_assert_cmpuint(month, ==, td[0].month);
g_assert_cmpuint(day, ==, td[0].day);
g_assert_cmpuint(hour, ==, td[0].hour);
gswe_assert_fuzzy_equals(minute, td[0].minute, 1);
/* The following lines are commented out, as they will always fail
* with the current precision of the test data.
g_assert_cmpuint(minute, ==, td[0].minute);
g_assert_cmpuint(second, ==, td[0].second);
g_assert_cmpuint(ms, ==, td[0].ms);
*/
g_assert_cmpfloat(tz, ==, td[0].tz); }
/* Sidereal time tests */
static void static void
test_timestamp_sidereal(void) test_timestamp_sidereal(void)
{} {}
/* timestamp_now_* tests */
static void static void
test_timestamp_now(void) test_timestamp_now(void)
{} {}