Makefile-test.am 12.4 KB
Newer Older
1 2 3 4
EXTRA_DIST += 			\
	test/test-bus.conf	\
	test/run-test		\
	$(NULL)
5

6 7
if XVFB_TESTS
XVFB_INVOCATION = $(XVFB) -ac -noreset -screen 0 1024x768x16
Iain Lane's avatar
Iain Lane committed
8 9 10 11 12 13 14
XIDS = 101 102 103 104 105 106 107 197 199 211 223 227 293 307 308 309 310 311 \
   491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 \
   991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 \
  1008 1009 4703 4721 4723 4729 4733 4751 9973 9974 9975 9976 9977 9978 9979 \
  9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 \
  9995 9996 9997 9998 9999
XVFB_START = \
15
${XVFB_INVOCATION} -help 2>/dev/null 1>&2 \
16 17 18 19
	&& XID=`for id in $(XIDS) ; do test -e /tmp/.X$$id-lock || { echo $$id; exit 0; }; done; exit 1` \
	&& { ${XVFB} :$$XID -nolisten tcp -auth /dev/null >/dev/null 2>&1 & \
		trap "kill -15 $$! " 0 HUP INT QUIT TRAP USR1 PIPE TERM ; } \
	|| { echo "Gtk+Tests:ERROR: Failed to start Xvfb environment for X11 target tests."; exit 1; } \
20
	&& export DISPLAY=:$$XID;
21 22 23
else
XVFB_START =
endif
Iain Lane's avatar
Iain Lane committed
24

25
### TEST RESOURCES #####################################################
Lucas Almeida Rocha's avatar
Lucas Almeida Rocha committed
26

27
mock_js_resources_files := $(shell glib-compile-resources --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/test/mock-js-resources.gresource.xml)
28 29 30 31 32
mock-js-resources.h: $(srcdir)/test/mock-js-resources.gresource.xml $(modules_resource_files)
	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --sourcedir=$(builddir) --generate --c-name mock_js_resources $<
mock-js-resources.c: $(srcdir)/test/mock-js-resources.gresource.xml $(modules_resource_files)
	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --sourcedir=$(builddir) --generate --c-name mock_js_resources $<

33 34 35 36 37 38 39 40
jsunit_resources_files := $(shell glib-compile-resources --sourcedir=$(srcdir)/installed-tests/js --generate-dependencies $(srcdir)/installed-tests/js/jsunit.gresources.xml)
jsunit-resources.h: $(srcdir)/installed-tests/js/jsunit.gresources.xml $(jsunit_resources_files)
	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir)/installed-tests/js --sourcedir=$(builddir) --generate --c-name jsunit_resources $<
jsunit-resources.c: $(srcdir)/installed-tests/js/jsunit.gresources.xml $(jsunit_resources_files)
	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir)/installed-tests/js --sourcedir=$(builddir) --generate --c-name jsunit_resources $<

BUILT_SOURCES += mock-js-resources.c jsunit-resources.h jsunit-resources.c

41 42 43
EXTRA_DIST += 							\
	$(mock_js_resources_files)				\
	$(srcdir)/test/mock-js-resources.gresource.xml		\
44 45 46 47 48 49 50
	$(jsunit_resources_files)				\
	$(NULL)

CLEANFILES +=						\
	mock-js-resources.c				\
	jsunit-resources.c				\
	jsunit-resources.h				\
51
	$(NULL)
52

53 54
### TEST PROGRAMS ######################################################

55 56
# gjs-tests.gtester checks private APIs and is run only uninstalled,
# on "make check".
57 58 59 60 61
#
# jsunit checks public APIs using JS test scripts, and is run on "make check",
# as well as installed if --enable-installed-tests is given at configure time.
# See Makefile-insttest.am for the build rules installing the tests.

62
check_PROGRAMS += gjs-tests.gtester minijasmine
63

64
gjs_tests_gtester_CPPFLAGS =			\
65 66
	$(AM_CPPFLAGS)				\
	-DGJS_COMPILATION			\
67
	$(GJS_CFLAGS)				\
68 69 70
	$(gjs_directory_defines)		\
	-I$(top_srcdir)/test

71
gjs_tests_gtester_LDADD =	\
72
	libgjs.la		\
73
	$(GJS_LIBS)
Lucas Almeida Rocha's avatar
Lucas Almeida Rocha committed
74

75
gjs_tests_gtester_SOURCES =				\
76
	test/gjs-tests.cpp				\
77 78
	test/gjs-test-common.cpp			\
	test/gjs-test-common.h				\
79 80
	test/gjs-test-utils.cpp				\
	test/gjs-test-utils.h				\
81
	test/gjs-test-call-args.cpp			\
82
	test/gjs-test-coverage.cpp			\
83
	test/gjs-test-rooting.cpp			\
84 85 86
	mock-js-resources.c				\
	$(NULL)

87 88 89 90 91 92 93
minijasmine_SOURCES =			\
	installed-tests/minijasmine.cpp	\
	jsunit-resources.c		\
	jsunit-resources.h		\
	$(NULL)

minijasmine_CPPFLAGS =				\
94 95 96
	$(AM_CPPFLAGS)				\
	$(GJS_CFLAGS)				\
	-I$(top_srcdir)				\
97
	-DINSTTESTDIR=\"$(gjsinsttestdir)\"	\
98
	-DPKGLIBDIR=\"$(pkglibdir)\"		\
99 100
	$(NULL)

101
minijasmine_LDADD = $(GJS_LIBS) libgjs.la
Lucas Almeida Rocha's avatar
Lucas Almeida Rocha committed
102

103 104 105
### TEST GIRS ##########################################################

TEST_INTROSPECTION_GIRS =
106
common_test_ldflags = $(AM_LDFLAGS) -avoid-version
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
common_test_libadd = $(GJS_LIBS)

if !BUILDOPT_INSTALL_TESTS
# This rpath /nowhere thing is the libtool upstream recommended way to
# force generation of shared libraries, which we need in order for the
# tests to work uninstalled.
common_test_ldflags += -rpath /nowhere
# In the installed tests case, these libraries are built for pkglibdir; sadly we
# can only have one destination at a time
check_LTLIBRARIES += libregress.la libwarnlib.la libgimarshallingtests.la
endif

# These sources are installed as part of gobject-introspection, and symlinked
# into the build directory at configure time. They should not be distributed
# with GJS.
nodist_libregress_la_SOURCES =		\
	installed-tests/regress.c	\
	installed-tests/regress.h	\
	$(NULL)
libregress_la_CPPFLAGS = $(AM_CPPFLAGS) $(GJS_CFLAGS) $(GJS_GDBUS_CFLAGS)
libregress_la_LDFLAGS = $(common_test_ldflags) $(GJS_GDBUS_LIBS)
libregress_la_LIBADD = $(common_test_libadd)
libregress_scannerflags_includes = --include=Gio-2.0
if ENABLE_CAIRO
libregress_la_CPPFLAGS += $(GJS_CAIRO_CFLAGS)
libregress_la_LDFLAGS +=  $(GJS_CAIRO_LIBS)
libregress_scannerflags_includes += --include=cairo-1.0
else
libregress_la_CPPFLAGS += -D_GI_DISABLE_CAIRO
endif
Regress-1.0.gir: libregress.la
Regress_1_0_gir_LIBS = libregress.la
Regress_1_0_gir_FILES = $(nodist_libregress_la_SOURCES)
Regress_1_0_gir_SCANNERFLAGS =			\
	--warn-all --warn-error			\
	$(libregress_scannerflags_includes)	\
	$(WARN_SCANNERFLAGS)			\
	$(NULL)
if !ENABLE_CAIRO
Regress_1_0_gir_CFLAGS = -D_GI_DISABLE_CAIRO
endif
TEST_INTROSPECTION_GIRS += Regress-1.0.gir

nodist_libwarnlib_la_SOURCES =		\
	installed-tests/warnlib.c	\
	installed-tests/warnlib.h	\
	$(NULL)
libwarnlib_la_CPPFLAGS = $(AM_CPPFLAGS) $(GJS_CFLAGS)
libwarnlib_la_LDFLAGS = $(common_test_ldflags)
libwarnlib_la_LIBADD = $(common_test_libadd)
WarnLib-1.0.gir: libwarnlib.la
WarnLib_1_0_gir_LIBS = libwarnlib.la
WarnLib_1_0_gir_INCLUDES = Gio-2.0
WarnLib_1_0_gir_FILES = $(nodist_libwarnlib_la_SOURCES)
WarnLib_1_0_gir_SCANNERFLAGS =		\
	--c-include="warnlib.h"		\
	--symbol-prefix=warnlib_	\
	$(NULL)
TEST_INTROSPECTION_GIRS += WarnLib-1.0.gir

nodist_libgimarshallingtests_la_SOURCES =	\
	installed-tests/gimarshallingtests.c	\
	installed-tests/gimarshallingtests.h	\
	$(NULL)
libgimarshallingtests_la_CPPFLAGS = $(AM_CPPFLAGS) $(GJS_CFLAGS)
libgimarshallingtests_la_LDFLAGS = $(common_test_ldflags)
libgimarshallingtests_la_LIBADD = $(common_test_libadd)
GIMarshallingTests-1.0.gir: libgimarshallingtests.la
GIMarshallingTests_1_0_gir_LIBS = libgimarshallingtests.la
GIMarshallingTests_1_0_gir_INCLUDES = Gio-2.0
GIMarshallingTests_1_0_gir_FILES = $(nodist_libgimarshallingtests_la_SOURCES)
GIMarshallingTests_1_0_gir_SCANNERFLAGS =	\
	--symbol-prefix=gi_marshalling_tests	\
	--warn-all --warn-error			\
	$(WARN_SCANNERFLAGS)			\
	$(NULL)
TEST_INTROSPECTION_GIRS += GIMarshallingTests-1.0.gir

$(foreach gir,$(TEST_INTROSPECTION_GIRS),$(eval $(call introspection-scanner,$(gir))))
TEST_INTROSPECTION_TYPELIBS = $(TEST_INTROSPECTION_GIRS:.gir=.typelib)
noinst_DATA += $(TEST_INTROSPECTION_TYPELIBS)
CLEANFILES += $(TEST_INTROSPECTION_GIRS) $(TEST_INTROSPECTION_TYPELIBS)

### JAVASCRIPT TESTS ###################################################

common_jstests_files =						\
	installed-tests/js/testself.js				\
	installed-tests/js/testByteArray.js			\
	installed-tests/js/testExceptions.js			\
	installed-tests/js/testEverythingBasic.js		\
	installed-tests/js/testEverythingEncapsulated.js	\
	installed-tests/js/testFormat.js			\
	installed-tests/js/testFundamental.js			\
	installed-tests/js/testGettext.js			\
	installed-tests/js/testGIMarshalling.js			\
202
	installed-tests/js/testGLib.js				\
203 204
	installed-tests/js/testGObjectClass.js			\
	installed-tests/js/testGObjectInterface.js		\
205
	installed-tests/js/testGTypeClass.js			\
206
	installed-tests/js/testGio.js				\
207 208
	installed-tests/js/testImporter.js			\
	installed-tests/js/testLang.js				\
209
	installed-tests/js/testLegacyByteArray.js		\
210
	installed-tests/js/testLegacyClass.js			\
211
	installed-tests/js/testLegacyGObject.js			\
212 213 214
	installed-tests/js/testLocale.js			\
	installed-tests/js/testMainloop.js			\
	installed-tests/js/testNamespace.js			\
215
	installed-tests/js/testPackage.js			\
216 217 218 219 220 221
	installed-tests/js/testParamSpec.js			\
	installed-tests/js/testSignals.js			\
	installed-tests/js/testSystem.js			\
	installed-tests/js/testTweener.js			\
	$(NULL)

222 223 224 225 226 227 228
jasmine_tests = $(common_jstests_files)

if DBUS_TESTS
jasmine_tests += installed-tests/js/testGDBus.js
endif

if ENABLE_GTK
229 230 231 232
jasmine_tests += 				                \
	installed-tests/js/testGtk.js		                \
	installed-tests/js/testGObjectDestructionAccess.js	\
	installed-tests/js/testLegacyGtk.js	                \
233
	$(NULL)
234 235 236 237

GTK_TESTS_ENVIRONMENT = export ENABLE_GTK=yes;
else
GTK_TESTS_ENVIRONMENT =
238 239 240 241 242 243
endif

if ENABLE_CAIRO
jasmine_tests += installed-tests/js/testCairo.js
endif

244 245 246 247 248 249 250 251 252
EXTRA_DIST +=						        \
	$(common_jstests_files)				        \
	installed-tests/js/testCairo.js			        \
	installed-tests/js/testGtk.js			        \
	installed-tests/js/testGDBus.js			        \
	installed-tests/js/testGObjectDestructionAccess.js	\
	installed-tests/js/testLegacyGtk.js		        \
	installed-tests/extra/gjs.supp			        \
	installed-tests/extra/lsan.supp			        \
253 254 255 256
	$(NULL)

### TEST EXECUTION #####################################################

257 258 259 260 261 262
@VALGRIND_CHECK_RULES@
VALGRIND_SUPPRESSIONS_FILES = 				\
	$(datadir)/glib-2.0/valgrind/glib.supp		\
	$(top_srcdir)/installed-tests/extra/gjs.supp	\
	$(NULL)

263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
if DBUS_TESTS
DBUS_SESSION_COMMAND = $(DBUS_RUN_SESSION) --config-file=$(srcdir)/test/test-bus.conf --
else
DBUS_SESSION_COMMAND =
endif

if CODE_COVERAGE_ENABLED
COVERAGE_TESTS_ENVIRONMENT = 						\
	export GJS_UNIT_COVERAGE_OUTPUT=lcov;				\
	export GJS_UNIT_COVERAGE_PREFIX=resource:///org/gnome/gjs/;	\
	$(NULL)
else
COVERAGE_TESTS_ENVIRONMENT =
endif

278
# GJS_PATH is empty here since we want to force the use of our own
279 280 281 282 283
# resources. G_FILENAME_ENCODING ensures filenames are not UTF-8.
AM_TESTS_ENVIRONMENT =					\
	export TOP_BUILDDIR="$(abs_top_builddir)";	\
	export GJS_USE_UNINSTALLED_FILES=1;		\
	export GJS_PATH=;				\
284 285
	export GI_TYPELIB_PATH="$(builddir):$${GI_TYPELIB_PATH:+:$$GI_TYPELIB_PATH}"; \
	export LD_LIBRARY_PATH="$(builddir)/.libs:$${LD_LIBRARY_PATH:+:$$LD_LIBRARY_PATH}"; \
286
	export G_FILENAME_ENCODING=latin1;		\
287
	export LSAN_OPTIONS="suppressions=$(abs_top_srcdir)/installed-tests/extra/lsan.supp"; \
288
	export NO_AT_BRIDGE=1;				\
289
	export LC_ALL=$(TESTS_LOCALE);			\
290
	$(COVERAGE_TESTS_ENVIRONMENT)			\
291
	$(GTK_TESTS_ENVIRONMENT)			\
292
	$(XVFB_START)					\
293
	$(DBUS_SESSION_COMMAND)				\
294
	$(NULL)
295

296 297 298 299
simple_tests =						\
	installed-tests/scripts/testCommandLine.sh	\
	installed-tests/scripts/testWarnings.sh		\
	$(NULL)
300
EXTRA_DIST += $(simple_tests)
301

Philip Chimento's avatar
Philip Chimento committed
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
debugger_tests =					\
	installed-tests/debugger/backtrace.debugger	\
	installed-tests/debugger/breakpoint.debugger	\
	installed-tests/debugger/continue.debugger	\
	installed-tests/debugger/delete.debugger	\
	installed-tests/debugger/detach.debugger	\
	installed-tests/debugger/down-up.debugger	\
	installed-tests/debugger/finish.debugger	\
	installed-tests/debugger/frame.debugger		\
	installed-tests/debugger/keys.debugger		\
	installed-tests/debugger/next.debugger		\
	installed-tests/debugger/print.debugger		\
	installed-tests/debugger/quit.debugger		\
	installed-tests/debugger/return.debugger	\
	installed-tests/debugger/set.debugger		\
	installed-tests/debugger/step.debugger		\
	installed-tests/debugger/throw.debugger		\
	installed-tests/debugger/until.debugger		\
	$(NULL)
EXTRA_DIST +=				\
	$(debugger_tests)		\
	$(debugger_tests:%=%.js)	\
	$(debugger_tests:%=%.output)	\
	$(NULL)

327
TESTS =				\
328
	gjs-tests.gtester	\
329 330
	$(simple_tests)		\
	$(jasmine_tests)	\
Philip Chimento's avatar
Philip Chimento committed
331
	$(debugger_tests)	\
332 333
	$(NULL)

Philip Chimento's avatar
Philip Chimento committed
334
TEST_EXTENSIONS = .gtester .sh .js .debugger
335 336

LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh
337 338 339 340 341

GTESTER_LOG_DRIVER = $(LOG_DRIVER)
GTESTER_LOG_COMPILER = $(top_srcdir)/test/run-test

SH_LOG_DRIVER = $(LOG_DRIVER)
342 343

JS_LOG_DRIVER = $(LOG_DRIVER)
344
JS_LOG_COMPILER = $$LOG_COMPILER $$LOG_FLAGS $(top_builddir)/minijasmine
345

Philip Chimento's avatar
Philip Chimento committed
346 347
DEBUGGER_LOG_DRIVER = $(LOG_DRIVER)
DEBUGGER_LOG_COMPILER = $(top_srcdir)/installed-tests/debugger-test.sh
Philip Chimento's avatar
Philip Chimento committed
348
EXTRA_DIST += installed-tests/debugger-test.sh
Philip Chimento's avatar
Philip Chimento committed
349

350
CODE_COVERAGE_IGNORE_PATTERN = */{include,mfbt,gjs/test}/*
351
CODE_COVERAGE_GENHTML_OPTIONS = 			\
352
	$(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT)	\
353 354 355 356 357
	lcov/coverage.lcov 				\
	--prefix $(abs_top_builddir)/lcov/org/gnome/gjs	\
	--prefix $(abs_top_builddir) 			\
	$(NULL)
@CODE_COVERAGE_RULES@