summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.gitmodules3
-rw-r--r--Makefile.am6
-rw-r--r--configure.ac7
-rw-r--r--docs/reference/webhelper/Makefile.am.inc2
-rw-r--r--jasmine.json5
-rw-r--r--test/Makefile.am.inc53
-rw-r--r--test/demos/Makefile.am.inc5
-rw-r--r--test/demos/flexy-grid.c107
-rw-r--r--test/endless/Makefile.am.inc20
m---------test/jasmine0
-rw-r--r--test/smoke-tests/Makefile.am.inc20
-rw-r--r--test/tools/eos-application-manifest/testInit.js552
-rw-r--r--test/tools/eos-run-test/sanitycheck.js3
-rw-r--r--tools/Makefile.am.inc1
-rw-r--r--tools/eos-run-test.in147
16 files changed, 343 insertions, 590 deletions
diff --git a/.gitignore b/.gitignore
index 3c8c7a1..525f885 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,7 +8,6 @@ Endless-0.gir
Endless-0.typelib
endless/eosresource.c
endless/eosresource-private.h
-tools/eos-run-test
tools/eos-application-manifest/eos-application-manifest
tools/eos-json-extractor/eos-json-extractor
@@ -45,6 +44,7 @@ stamp*
/m4/ltsugar.m4
/m4/ltversion.m4
/m4/serial-tests.m4
+/tap-driver.sh
/test-driver
.dirstamp
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index beb3d46..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "test/jasmine"]
- path = test/jasmine
- url = git@github.com:endlessm/eos-jasmine.git
diff --git a/Makefile.am b/Makefile.am
index 51f1d7c..467f047 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,6 +16,8 @@ ACLOCAL_AMFLAGS = -I m4
# Extra files to distribute in the tarball
EXTRA_DIST = README.md @EOS_SDK_API_NAME@.pc.in
+# As above, but files in dist_noinst_DATA also need to be built by make
+dist_noinst_DATA =
# Compiler flags
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
@@ -31,9 +33,9 @@ DISTCLEANFILES =
# Make sure that 'make dist' includes documentation
if CAN_MAKE_DIST
-dist-hook:
+dist-hook::
else
-dist-hook:
+dist-hook::
@echo "***"
@echo "*** You must configure with --enable-gtk-doc, --enable-gir-doc, and"
@echo "*** --enable-js-doc to run make dist or make distcheck."
diff --git a/configure.ac b/configure.ac
index 2be3f63..c71973e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,7 +40,9 @@ dnl AC_CONFIG_SRCDIR([src/hello.c])
# Unlike serial-tests, this option is accepted by Automake 1.11
# tar-ustar is required because there may be files whose entire paths exceed
# 99 characters.
-AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign 1.11 parallel-tests tar-ustar])
+# subdir-objects is for forward compatibility with Automake 2.0 and can be
+# removed when we upgrade to that version.
+AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign 1.11 parallel-tests tar-ustar subdir-objects])
# Avoid spewing garbage over the terminal ('make V=1' to see the garbage)
AM_SILENT_RULES([yes])
# Initialize Libtool; don't build static libraries
@@ -114,6 +116,8 @@ GTK_DOC_CHECK([1.18], [--flavour no-tmpl])
# GObject Introspection
GOBJECT_INTROSPECTION_REQUIRE([1.30])
# Various tools
+AC_PROG_AWK # needed for TAP driver
+AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_PATH_PROG([GIRDOCTOOL], [g-ir-doc-tool], [notfound])
AC_ARG_VAR([GIRDOCTOOL], [Path to g-ir-doc-tool])
AC_PATH_PROG([YELPBUILD], [yelp-build], [notfound])
@@ -220,7 +224,6 @@ AC_CONFIG_FILES([
$EOS_SDK_API_NAME.pc
tools/eos-json-extractor/eos-json-extractor
])
-AC_CONFIG_FILES([tools/eos-run-test], [chmod +x tools/eos-run-test])
AC_CONFIG_HEADERS([config.h]) dnl Header with system-dependent #defines
# Make docs/reference/webhelper/eos.css available in the build tree as well as
# the source tree
diff --git a/docs/reference/webhelper/Makefile.am.inc b/docs/reference/webhelper/Makefile.am.inc
index 3b47e19..55caccf 100644
--- a/docs/reference/webhelper/Makefile.am.inc
+++ b/docs/reference/webhelper/Makefile.am.inc
@@ -24,7 +24,7 @@ DISTCLEANFILES += \
distclean-local:
@rm -rf docs/reference/webhelper/html
-dist-hook:
+dist-hook::
@mkdir -p $(distdir)/docs/reference/webhelper/html
@cp -r docs/reference/webhelper/html/* $(distdir)/docs/reference/webhelper/html
diff --git a/jasmine.json b/jasmine.json
new file mode 100644
index 0000000..aebe0bd
--- /dev/null
+++ b/jasmine.json
@@ -0,0 +1,5 @@
+{
+ "include_paths": ["webhelper", "."],
+ "options": "--verbose",
+ "spec_files": ["test/webhelper", "test/tools/eos-application-manifest"]
+}
diff --git a/test/Makefile.am.inc b/test/Makefile.am.inc
index 921700b..dc90227 100644
--- a/test/Makefile.am.inc
+++ b/test/Makefile.am.inc
@@ -2,42 +2,73 @@
TEST_FLAGS = @EOS_SDK_CFLAGS@ -I$(top_srcdir) -DCOMPILING_EOS_SDK
TEST_LIBS = @EOS_SDK_LIBS@ $(top_builddir)/libendless-@EOS_SDK_API_VERSION@.la
-ENDLESS_TESTS_DIRECTORY = $(top_srcdir)/test
noinst_PROGRAMS = \
test/endless/run-tests \
test/smoke-tests/hello \
- test/demos/flexy-grid
+ $(NULL)
+
+test_endless_run_tests_SOURCES = \
+ test/endless/run-tests.c \
+ test/endless/run-tests.h \
+ test/endless/test-init.c \
+ test/endless/test-hello.c \
+ test/endless/test-application.c \
+ test/endless/test-page-manager.c \
+ test/endless/test-window.c \
+ test/endless/test-flexy-grid.c \
+ test/endless/test-custom-container.c \
+ $(NULL)
+test_endless_run_tests_CPPFLAGS = $(TEST_FLAGS)
+test_endless_run_tests_LDADD = $(TEST_LIBS)
+
+test_smoke_tests_hello_SOURCES = test/smoke-tests/hello.c
+test_smoke_tests_hello_CPPFLAGS = $(TEST_FLAGS)
+test_smoke_tests_hello_LDADD = $(TEST_LIBS)
+
+credits_resource_files = \
+ test/smoke-tests/images/test1.jpg \
+ test/smoke-tests/images/test2.jpg \
+ test/smoke-tests/images/test3.jpg \
+ test/smoke-tests/images/attribution.json \
+ $(NULL)
+test/smoke-tests/images/credits.gresource: test/smoke-tests/images/credits.gresource.xml $(credits_resource_files)
+ $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/test/smoke-tests/images $<
+dist_noinst_DATA += test/smoke-tests/images/credits.gresource
+CLEANFILES += test/smoke-tests/images/credits.gresource
+EXTRA_DIST += \
+ test/smoke-tests/images/credits.gresource.xml \
+ $(credits_resource_files) \
+ $(NULL)
-# This variable will be updated in Makefile subdirs (test/endless/Makefile.am.inc)
javascript_tests = \
test/tools/eos-application-manifest/testInit.js \
test/webhelper/testTranslate.js \
test/webhelper/testWebActions.js \
test/webhelper/testUpdateFontSize.js \
+ test/endless/testCustomContainer.js \
+ test/endless/testTopbarNavButton.js \
$(NULL)
EXTRA_DIST += $(javascript_tests)
-include test/endless/Makefile.am.inc
-include test/demos/Makefile.am.inc
-include test/smoke-tests/Makefile.am.inc
-
# Run tests when running 'make check'
TESTS = \
test/endless/run-tests \
$(javascript_tests) \
$(NULL)
-TEST_EXTENSIONS =
+JS_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh
+JS_LOG_DRIVER_FLAGS = --comments
+TEST_EXTENSIONS = .js
+JS_LOG_COMPILER = jasmine
AM_JS_LOG_FLAGS = \
--include-path=$(top_srcdir)/webhelper \
--include-path=$(top_srcdir) \
+ --tap \
+ --no-config \
$(NULL)
LOG_COMPILER = gtester
AM_LOG_FLAGS = -k --verbose
-JASMINE_SUBMODULE_PATH = $(top_srcdir)/test/jasmine
-include test/jasmine/Makefile-jasmine.am.inc
-
# Use locally built versions of Endless-0.gir and libraries; this may need to be
# changed to AM_TESTS_ENVIRONMENT in a future version of Automake
# Set XDG_CONFIG_HOME so as to avoid cluttering the user's actual config
diff --git a/test/demos/Makefile.am.inc b/test/demos/Makefile.am.inc
deleted file mode 100644
index 797cfd3..0000000
--- a/test/demos/Makefile.am.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2013 Endless Mobile, Inc.
-
-test_demos_flexy_grid_SOURCES = $(ENDLESS_TESTS_DIRECTORY)/demos/flexy-grid.c
-test_demos_flexy_grid_CPPFLAGS = $(TEST_FLAGS)
-test_demos_flexy_grid_LDADD = $(TEST_LIBS)
diff --git a/test/demos/flexy-grid.c b/test/demos/flexy-grid.c
deleted file mode 100644
index 2008af4..0000000
--- a/test/demos/flexy-grid.c
+++ /dev/null
@@ -1,107 +0,0 @@
-#include <endless/endless.h>
-
-static const char *icons[] = {
- "applications-accessories",
- "applications-development",
- "applications-engineering",
- "applications-games",
- "applications-graphics",
- "applications-internet",
- "applications-multimedia",
- "applications-office",
- "applications-other",
- "applications-science",
- "applications-system",
- "applications-utilities",
-};
-
-#define CHAR(r,g,b) { r / 255.0, g / 255.0, b / 255.0, 1.0 }
-
-static GdkRGBA colors[] = {
- CHAR (0xff, 0x00, 0x00),
- CHAR (0x80, 0x00, 0x00),
- CHAR (0x00, 0xff, 0x00),
- CHAR (0x00, 0x80, 0x00),
- CHAR (0x00, 0x00, 0xff),
- CHAR (0x00, 0x00, 0x80),
- CHAR (0x00, 0xff, 0xff),
- CHAR (0x00, 0x80, 0x80),
- CHAR (0xff, 0x00, 0xff),
- CHAR (0x80, 0x00, 0x80),
- CHAR (0xff, 0xff, 0x00),
- CHAR (0x80, 0x80, 0x00),
- CHAR (0xa0, 0xa0, 0xa4),
- CHAR (0x80, 0x80, 0x80),
- CHAR (0xc0, 0xc0, 0xc0),
-};
-
-static EosFlexyShape shapes[] = {
- EOS_FLEXY_SHAPE_MEDIUM_HORIZONTAL,
- EOS_FLEXY_SHAPE_MEDIUM_VERTICAL,
- EOS_FLEXY_SHAPE_SMALL,
- EOS_FLEXY_SHAPE_SMALL,
- EOS_FLEXY_SHAPE_SMALL,
- EOS_FLEXY_SHAPE_MEDIUM_VERTICAL,
- EOS_FLEXY_SHAPE_MEDIUM_HORIZONTAL,
- EOS_FLEXY_SHAPE_SMALL,
-};
-
-static void
-on_cell_selected (EosFlexyGrid *grid, EosFlexyGridCell *cell)
-{
- g_print ("Cell %p selected\n", cell);
-}
-
-static void
-on_cell_activated (EosFlexyGrid *grid, EosFlexyGridCell *cell)
-{
- g_print ("Cell %p activated\n", cell);
-}
-
-int
-main (int argc, char *argv[])
-{
- gtk_init (NULL, NULL);
-
- GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
- gtk_widget_show (window);
-
- GtkWidget *scroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (window), scroll);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
- GTK_POLICY_NEVER,
- GTK_POLICY_AUTOMATIC);
- gtk_widget_show (scroll);
-
- GtkWidget *grid = eos_flexy_grid_new ();
- g_signal_connect (grid, "cell-selected", G_CALLBACK (on_cell_selected), NULL);
- g_signal_connect (grid, "cell-activated", G_CALLBACK (on_cell_activated), NULL);
- gtk_container_add (GTK_CONTAINER (scroll), grid);
- gtk_widget_show (grid);
-
- for (guint i = 0; i < 8; i++)
- {
- GtkWidget *cell = eos_flexy_grid_cell_new ();
- eos_flexy_grid_cell_set_shape (EOS_FLEXY_GRID_CELL (cell), shapes[i]);
- gtk_container_add (GTK_CONTAINER (grid), cell);
- gtk_widget_show (cell);
-
- GtkWidget *frame = gtk_event_box_new ();
- gtk_widget_override_background_color (frame, GTK_STATE_FLAG_NORMAL, &colors[i]);
- gtk_container_add (GTK_CONTAINER (cell), frame);
- gtk_widget_show (frame);
-
- GtkWidget *image = gtk_image_new ();
- gtk_image_set_from_icon_name (GTK_IMAGE (image), icons[i], GTK_ICON_SIZE_DIALOG);
- gtk_container_add (GTK_CONTAINER (frame), image);
- gtk_widget_set_hexpand (image, TRUE);
- gtk_widget_set_vexpand (image, TRUE);
- gtk_widget_show (image);
- }
-
- gtk_main ();
-
- return 0;
-}
diff --git a/test/endless/Makefile.am.inc b/test/endless/Makefile.am.inc
deleted file mode 100644
index 5e83d2f..0000000
--- a/test/endless/Makefile.am.inc
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2013 Endless Mobile, Inc.
-
-test_endless_run_tests_SOURCES = \
- $(ENDLESS_TESTS_DIRECTORY)/endless/run-tests.c \
- $(ENDLESS_TESTS_DIRECTORY)/endless/run-tests.h \
- $(ENDLESS_TESTS_DIRECTORY)/endless/test-init.c \
- $(ENDLESS_TESTS_DIRECTORY)/endless/test-hello.c \
- $(ENDLESS_TESTS_DIRECTORY)/endless/test-application.c \
- $(ENDLESS_TESTS_DIRECTORY)/endless/test-page-manager.c \
- $(ENDLESS_TESTS_DIRECTORY)/endless/test-window.c \
- $(ENDLESS_TESTS_DIRECTORY)/endless/test-flexy-grid.c \
- $(ENDLESS_TESTS_DIRECTORY)/endless/test-custom-container.c \
- $(NULL)
-test_endless_run_tests_CPPFLAGS = $(TEST_FLAGS)
-test_endless_run_tests_LDADD = $(TEST_LIBS)
-
-javascript_tests += \
- test/endless/testCustomContainer.js \
- test/endless/testTopbarNavButton.js \
- $(NULL)
diff --git a/test/jasmine b/test/jasmine
deleted file mode 160000
-Subproject 4ffce45612f0c03d756dc37ae9a66050d3f891d
diff --git a/test/smoke-tests/Makefile.am.inc b/test/smoke-tests/Makefile.am.inc
deleted file mode 100644
index 170b335..0000000
--- a/test/smoke-tests/Makefile.am.inc
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2013 Endless Mobile, Inc.
-
-test_smoke_tests_hello_SOURCES = $(ENDLESS_TESTS_DIRECTORY)/smoke-tests/hello.c
-test_smoke_tests_hello_CPPFLAGS = $(TEST_FLAGS)
-test_smoke_tests_hello_LDADD = $(TEST_LIBS)
-
-credits_resource_files = \
- test/smoke-tests/images/test1.jpg \
- test/smoke-tests/images/test2.jpg \
- test/smoke-tests/images/test3.jpg \
- test/smoke-tests/images/attribution.json \
- $(NULL)
-test/smoke-tests/images/credits.gresource: test/smoke-tests/images/credits.gresource.xml $(credits_resource_files)
- $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/test/smoke-tests/images $<
-dist_noinst_DATA = test/smoke-tests/images/credits.gresource
-CLEANFILES += test/smoke-tests/images/credits.gresource
-EXTRA_DIST += \
- test/smoke-tests/images/credits.gresource.xml \
- $(credits_resource_files) \
- $(NULL)
diff --git a/test/tools/eos-application-manifest/testInit.js b/test/tools/eos-application-manifest/testInit.js
index 70801ac..89c91d6 100644
--- a/test/tools/eos-application-manifest/testInit.js
+++ b/test/tools/eos-application-manifest/testInit.js
@@ -1,291 +1,309 @@
const Module = imports.tools['eos-application-manifest'].commands.init;
-function testParseOneArgumentWithoutValue() {
- let input = ['--parameter'];
- let expected = { parameter: null };
- let actual = Module.parseRemainingArgs(input);
- assertEquals(JSON.stringify(expected), JSON.stringify(actual));
-}
+describe('eos-application-manifest init', function () {
+ describe('argument parser', function () {
+ it('parses one argument without a value', function () {
+ let input = ['--parameter'];
+ let expected = {
+ parameter: null,
+ };
+ let actual = Module.parseRemainingArgs(input);
+ expect(JSON.stringify(actual)).toEqual(JSON.stringify(expected));
+ });
-function testParseOneArgumentWithValue() {
- let input = ['--parameter=value'];
- let expected = { parameter: "value" };
- let actual = Module.parseRemainingArgs(input);
- assertEquals(JSON.stringify(expected), JSON.stringify(actual));
-}
+ it('parses one argument with a value', function () {
+ let input = ['--parameter=value'];
+ let expected = {
+ parameter: 'value',
+ };
+ let actual = Module.parseRemainingArgs(input);
+ expect(JSON.stringify(actual)).toEqual(JSON.stringify(expected));
+ });
-function testParseOneArgumentFollowedByValue() {
- let input = ['--parameter', 'value'];
- let expected = { parameter: "value" };
- let actual = Module.parseRemainingArgs(input);
- assertEquals(JSON.stringify(expected), JSON.stringify(actual));
-}
+ it('parses one argument followed by a value', function () {
+ let input = ['--parameter', 'value'];
+ let expected = {
+ parameter: 'value',
+ };
+ let actual = Module.parseRemainingArgs(input);
+ expect(JSON.stringify(actual)).toEqual(JSON.stringify(expected));
+ });
-function testParseTwoArgumentsWithoutValue() {
- let input = ['--parameter-one', '--parameter-two'];
- let expected = { 'parameter-one': null, 'parameter-two': null };
- let actual = Module.parseRemainingArgs(input);
- assertEquals(JSON.stringify(expected), JSON.stringify(actual));
-}
+ it('parses two arguments without a value', function () {
+ let input = ['--parameter-one', '--parameter-two'];
+ let expected = {
+ 'parameter-one': null,
+ 'parameter-two': null,
+ };
+ let actual = Module.parseRemainingArgs(input);
+ expect(JSON.stringify(actual)).toEqual(JSON.stringify(expected));
+ });
-function testParseArgumentWithValueFollowedByArgument() {
- let input = ['--parameter-one=value', '--parameter-two'];
- let expected = { 'parameter-one': 'value', 'parameter-two': null };
- let actual = Module.parseRemainingArgs(input);
- assertEquals(JSON.stringify(expected), JSON.stringify(actual));
-}
+ it('parses an argument with a value followed by an argument', function () {
+ let input = ['--parameter-one=value', '--parameter-two'];
+ let expected = {
+ 'parameter-one': 'value',
+ 'parameter-two': null,
+ };
+ let actual = Module.parseRemainingArgs(input);
+ expect(JSON.stringify(actual)).toEqual(JSON.stringify(expected));
+ });
-function testParseArgumentFollowedByValueFollowedByArgument() {
- let input = ['--parameter-one', 'value', '--parameter-two'];
- let expected = { 'parameter-one': 'value', 'parameter-two': null };
- let actual = Module.parseRemainingArgs(input);
- assertEquals(JSON.stringify(expected), JSON.stringify(actual));
-}
+ it('parses an argument followed by a value followed by an argument', function () {
+ let input = ['--parameter-one', 'value', '--parameter-two'];
+ let expected = {
+ 'parameter-one': 'value',
+ 'parameter-two': null,
+ };
+ let actual = Module.parseRemainingArgs(input);
+ expect(JSON.stringify(actual)).toEqual(JSON.stringify(expected));
+ });
+ });
-function testValidateMinimalCorrectArgumentsWithAppclass() {
- let input = {
- appname: 'Smoke Grinder',
- author: 'Joe Coder <joe@coder.com>',
- appversion: '1.0',
- appclass: 'SmokeGrinder.App'
- };
- assertTrue(Module.validateRemainingArgs(input));
-}
+ it('validates minimal correct arguments with appclass', function () {
+ let input = {
+ appname: 'Smoke Grinder',
+ author: 'Joe Coder <joe@coder.com>',
+ appversion: '1.0',
+ appclass: 'SmokeGrinder.App',
+ };
+ expect(Module.validateRemainingArgs(input)).toBeTruthy();
+ });
-function testValidateMinimalCorrectArgumentsWithExec() {
- let input = {
- appname: 'Smoke Grinder',
- author: 'Joe Coder <joe@coder.com>',
- appversion: '1.0',
- exec: 'bin/smoke-grinder-launch'
- };
- assertTrue(Module.validateRemainingArgs(input));
-}
+ it('validates minimal correct arguments with exec', function () {
+ let input = {
+ appname: 'Smoke Grinder',
+ author: 'Joe Coder <joe@coder.com>',
+ appversion: '1.0',
+ exec: 'bin/smoke-grinder-launch',
+ };
+ expect(Module.validateRemainingArgs(input)).toBeTruthy();
+ });
-function testValidateMaximalCorrectArguments() {
- let input = {
- appname: 'Smoke Grinder',
- author: 'Joe Coder <joe@coder.com>',
- appversion: '1.0',
- appclass: 'SmokeGrinder.App',
- 'manifest-version': '0',
- website: 'http://coder.example.com',
- description: 'An app that does exciting things',
- locale: 'en',
- license: 'GPL'
- };
- assertTrue(Module.validateRemainingArgs(input));
-}
+ it('validates maximal correct arguments', function () {
+ let input = {
+ appname: 'Smoke Grinder',
+ author: 'Joe Coder <joe@coder.com>',
+ appversion: '1.0',
+ appclass: 'SmokeGrinder.App',
+ 'manifest-version': '0',
+ website: 'http://coder.example.com',
+ description: 'An app that does exciting things',
+ locale: 'en',
+ license: 'GPL',
+ };
+ expect(Module.validateRemainingArgs(input)).toBeTruthy();
+ });
-function testValidateBadArgumentsAppnameMissing() {
- let input = {
- author: 'Joe Coder <joe@coder.com>',
- appversion: '1.0',
- appclass: 'SmokeGrinder.App'
- };
- assertFalse(Module.validateRemainingArgs(input));
-}
+ it('requires an appname', function () {
+ let input = {
+ author: 'Joe Coder <joe@coder.com>',
+ appversion: '1.0',
+ appclass: 'SmokeGrinder.App',
+ };
+ expect(Module.validateRemainingArgs(input)).toBeFalsy();
+ });
-function testValidateBadArgumentsAuthorMissing() {
- let input = {
- appname: 'Smoke Grinder',
- appversion: '1.0',
- appclass: 'SmokeGrinder.App'
- };
- assertFalse(Module.validateRemainingArgs(input));
-}
+ it('requires an author', function () {
+ let input = {
+ appname: 'Smoke Grinder',
+ appversion: '1.0',
+ appclass: 'SmokeGrinder.App',
+ };
+ expect(Module.validateRemainingArgs(input)).toBeFalsy();
+ });
-function testValidateBadArgumentsAppversionMissing() {
- let input = {
- appname: 'Smoke Grinder',
- author: 'Joe Coder <joe@coder.com>',
- appclass: 'SmokeGrinder.App'
- };
- assertFalse(Module.validateRemainingArgs(input));
-}
+ it('requires an app version', function () {
+ let input = {
+ appname: 'Smoke Grinder',
+ author: 'Joe Coder <joe@coder.com>',
+ appclass: 'SmokeGrinder.App',
+ };
+ expect(Module.validateRemainingArgs(input)).toBeFalsy();
+ });
-function testValidateBadArgumentsLauncherMissing() {
- let input = {
- appname: 'Smoke Grinder',
- author: 'Joe Coder <joe@coder.com>',
- appversion: '1.0',
- };
- assertFalse(Module.validateRemainingArgs(input));
-}
+ it('requires a launcher item', function () {
+ let input = {
+ appname: 'Smoke Grinder',
+ author: 'Joe Coder <joe@coder.com>',
+ appversion: '1.0',
+ };
+ expect(Module.validateRemainingArgs(input)).toBeFalsy();
+ });
-function testValidateBadArgumentsTooManyLaunchers() {
- let input = {
- appname: 'Smoke Grinder',
- author: 'Joe Coder <joe@coder.com>',
- appversion: '1.0',
- appclass: 'SmokeGrinder.App',
- exec: 'bin/smoke-grinder-launch'
- };
- assertFalse(Module.validateRemainingArgs(input));
-}
+ it('does not allow more than one launcher item', function () {
+ let input = {
+ appname: 'Smoke Grinder',
+ author: 'Joe Coder <joe@coder.com>',
+ appversion: '1.0',
+ appclass: 'SmokeGrinder.App',
+ exec: 'bin/smoke-grinder-launch',
+ };
+ expect(Module.validateRemainingArgs(input)).toBeFalsy();
+ });
-function testValidateBadUnknownArgument() {
- let input = {
- appname: 'Smoke Grinder',
- author: 'Joe Coder <joe@coder.com>',
- appversion: '1.0',
- appclass: 'SmokeGrinder.App',
- unrecognized_argument: 'a value'
- };
- assertFalse(Module.validateRemainingArgs(input));
-}
+ it('chokes on unknown arguments', function () {
+ let input = {
+ appname: 'Smoke Grinder',
+ author: 'Joe Coder <joe@coder.com>',
+ appversion: '1.0',
+ appclass: 'SmokeGrinder.App',
+ unrecognized_argument: 'a value',
+ };
+ expect(Module.validateRemainingArgs(input)).toBeFalsy();
+ });
-function testValidateBadArgumentsWithoutValues() {
- let input = {
- appname: null,
- author: null,
- appversion: null,
- appclass: null
- };
- assertFalse(Module.validateRemainingArgs(input));
-}
+ it('knows when arguments should have values', function () {
+ let input = {
+ appname: null,
+ author: null,
+ appversion: null,
+ appclass: null,
+ };
+ expect(Module.validateRemainingArgs(input)).toBeFalsy();
+ });
-function testValidateBadManifestVersion() {
- let input = {
- appname: 'Smoke Grinder',
- author: 'Joe Coder <joe@coder.com>',
- appversion: '1.0',
- appclass: 'SmokeGrinder.App',
- 'manifest-version': 'FF'
- };
- assertFalse(Module.validateRemainingArgs(input));
-}
+ it('rejects a bad manifest version', function () {
+ let input = {
+ appname: 'Smoke Grinder',
+ author: 'Joe Coder <joe@coder.com>',
+ appversion: '1.0',
+ appclass: 'SmokeGrinder.App',
+ 'manifest-version': 'FF',
+ };
+ expect(Module.validateRemainingArgs(input)).toBeFalsy();
+ });
-function testValidateTooHighManifestVersion() {
- let input = {
- appname: 'Smoke Grinder',
- author: 'Joe Coder <joe@coder.com>',
- appversion: '1.0',
- appclass: 'SmokeGrinder.App',
- 'manifest-version': 99999
- };
- assertFalse(Module.validateRemainingArgs(input));
-}
+ it('rejects a manifest version that is too high', function () {
+ let input = {
+ appname: 'Smoke Grinder',
+ author: 'Joe Coder <joe@coder.com>',
+ appversion: '1.0',
+ appclass: 'SmokeGrinder.App',
+ 'manifest-version': 99999,
+ };
+ expect(Module.validateRemainingArgs(input)).toBeFalsy();
+ });
-function testCreateFilenameForManifest() {
- let input = {
- applicationId: 'com.endlessm.smoke-grinder'
- };
- let expected = 'com.endlessm.smoke-grinder.json';
- let actual = Module.createFilenameForManifest(input);
-}
+ it('creates the correct filename for the manifest', function () {
+ let input = {
+ applicationId: 'com.endlessm.smoke-grinder',
+ };
+ expect(Module.createFilenameForManifest(input))
+ .toEqual('com.endlessm.smoke-grinder.json');
+ });
-function testCreateManifestFromMinimalArgsWithAppclass() {
- let inputApplicationId = 'com.coder.smoke-grinder';
- let inputArgDict = {
- appname: 'Smoke Grinder',
- author: 'Joe Coder <joe@coder.com>',
- appversion: '1.0.1',
- appclass: 'SmokeGrinder.App'
- };
- let expected = {
- manifestVersion: 1,
- applicationId: "com.coder.smoke-grinder",
- applicationName: {
- en: "Smoke Grinder"
- },
- authorName: "Joe Coder <joe@coder.com>",
- authorWebsite: "",
- description: {
- en: ""
- },
- version: "1.0.1",
- changes: {
- en: [],
- },
- license: "",
- resources: [],
- applicationClass: "SmokeGrinder.App",
- icons: {},
- categories: [],
- permissions: [],
- metadata: {}
- };
- let actual = Module.createManifest(inputApplicationId, inputArgDict);
- assertEquals(JSON.stringify(expected), JSON.stringify(actual));
-}
+ it('creates a whole manifest from minimal args, with appclass', function () {
+ let inputApplicationId = 'com.coder.smoke-grinder';
+ let inputArgDict = {
+ appname: 'Smoke Grinder',
+ author: 'Joe Coder <joe@coder.com>',
+ appversion: '1.0.1',
+ appclass: 'SmokeGrinder.App',
+ };
+ let expected = {
+ manifestVersion: 1,
+ applicationId: 'com.coder.smoke-grinder',
+ applicationName: {
+ en: 'Smoke Grinder',
+ },
+ authorName: 'Joe Coder <joe@coder.com>',
+ authorWebsite: '',
+ description: {
+ en: '',
+ },
+ version: '1.0.1',
+ changes: {
+ en: [],
+ },
+ license: '',
+ resources: [],
+ applicationClass: 'SmokeGrinder.App',
+ icons: {},
+ categories: [],
+ permissions: [],
+ metadata: {},
+ };
+ let actual = Module.createManifest(inputApplicationId, inputArgDict);
+ expect(JSON.stringify(actual)).toEqual(JSON.stringify(expected));
+ });
-function testCreateManifestFromMinimalArgsWithExec() {
- let inputApplicationId = 'com.coder.smoke-grinder';
- let inputArgDict = {
- appname: 'Smoke Grinder',
- author: 'Joe Coder <joe@coder.com>',
- appversion: '1.0.1',
- exec: 'bin/smoke-grinder-launch'
- };
- let expected = {
- manifestVersion: 1,
- applicationId: "com.coder.smoke-grinder",
- applicationName: {
- en: "Smoke Grinder"
- },
- authorName: "Joe Coder <joe@coder.com>",
- authorWebsite: "",
- description: {
- en: ""
- },
- version: "1.0.1",
- changes: {
- en: [],
- },
- license: "",
- resources: [],
- exec: "bin/smoke-grinder-launch",
- icons: {},
- categories: [],
- permissions: [],
- metadata: {}
- };
- let actual = Module.createManifest(inputApplicationId, inputArgDict);
- assertEquals(JSON.stringify(expected), JSON.stringify(actual));
-}
+ it('creates a whole manifest from minimal args, with exec', function () {
+ let inputApplicationId = 'com.coder.smoke-grinder';
+ let inputArgDict = {
+ appname: 'Smoke Grinder',
+ author: 'Joe Coder <joe@coder.com>',
+ appversion: '1.0.1',
+ exec: 'bin/smoke-grinder-launch',
+ };
+ let expected = {
+ manifestVersion: 1,
+ applicationId: 'com.coder.smoke-grinder',
+ applicationName: {
+ en: 'Smoke Grinder',
+ },
+ authorName: 'Joe Coder <joe@coder.com>',
+ authorWebsite: '',
+ description: {
+ en: '',
+ },
+ version: '1.0.1',
+ changes: {
+ en: [],
+ },
+ license: '',
+ resources: [],
+ exec: 'bin/smoke-grinder-launch',
+ icons: {},
+ categories: [],
+ permissions: [],
+ metadata: {},
+ };
+ let actual = Module.createManifest(inputApplicationId, inputArgDict);
+ expect(JSON.stringify(actual)).toEqual(JSON.stringify(expected));
+ });
-function testCreateManifestFromMaximalArgs() {
- let inputApplicationId = 'com.coder.smoke-grinder';
- let inputArgDict = {
- appname: 'Smoke Grinder',
- author: 'Joe Coder <joe@coder.com>',
- appversion: '1.0.1',
- appclass: 'SmokeGrinder.App',
- 'manifest-version': '0',
- website: 'http://coder.example.com',
- description: 'An app that does exciting things',
- locale: 'pt_BR',
- license: 'GPL'
- };
- let expected = {
- manifestVersion: 0,
- applicationId: "com.coder.smoke-grinder",
- applicationName: {
- pt_BR: "Smoke Grinder"
- },
- authorName: "Joe Coder <joe@coder.com>",
- authorWebsite: "http://coder.example.com",
- description: {
- pt_BR: "An app that does exciting things"
- },
- version: "1.0.1",
- changes: {
- pt_BR: [],
- },
- license: "GPL",
- resources: [],
- applicationClass: "SmokeGrinder.App",
- icons: {},
- categories: [],
- permissions: [],
- metadata: {}
- };
- let actual = Module.createManifest(inputApplicationId, inputArgDict);
- assertEquals(JSON.stringify(expected), JSON.stringify(actual));
-}
+ it('creates a whole manifest from maximal args', function () {
+ let inputApplicationId = 'com.coder.smoke-grinder';
+ let inputArgDict = {
+ appname: 'Smoke Grinder',
+ author: 'Joe Coder <joe@coder.com>',
+ appversion: '1.0.1',
+ appclass: 'SmokeGrinder.App',
+ 'manifest-version': '0',
+ website: 'http://coder.example.com',
+ description: 'An app that does exciting things',
+ locale: 'pt_BR',
+ license: 'GPL'
+ };
+ let expected = {
+ manifestVersion: 0,
+ applicationId: 'com.coder.smoke-grinder',
+ applicationName: {
+ pt_BR: 'Smoke Grinder'
+ },
+ authorName: 'Joe Coder <joe@coder.com>',
+ authorWebsite: 'http://coder.example.com',
+ description: {
+ pt_BR: 'An app that does exciting things'
+ },
+ version: '1.0.1',
+ changes: {
+ pt_BR: [],
+ },
+ license: 'GPL',
+ resources: [],
+ applicationClass: 'SmokeGrinder.App',
+ icons: {},
+ categories: [],
+ permissions: [],
+ metadata: {}
+ };
+ let actual = Module.createManifest(inputApplicationId, inputArgDict);
+ expect(JSON.stringify(actual)).toEqual(JSON.stringify(expected));
+ });
-function testSummary() {
- let summary = Module.summary();
- assertTrue(typeof summary == 'string');
-}
+ it('reports a subcommand summary for use in help', function () {
+ expect(typeof Module.summary()).toEqual('string');
+ });
+});
diff --git a/test/tools/eos-run-test/sanitycheck.js b/test/tools/eos-run-test/sanitycheck.js
deleted file mode 100644
index 4bb3a80..0000000
--- a/test/tools/eos-run-test/sanitycheck.js
+++ /dev/null
@@ -1,3 +0,0 @@
-function testNothing() {
- assertEquals(2, 2);
-} \ No newline at end of file
diff --git a/tools/Makefile.am.inc b/tools/Makefile.am.inc
index 47744b2..5c53d72 100644
--- a/tools/Makefile.am.inc
+++ b/tools/Makefile.am.inc
@@ -1,7 +1,6 @@
# Copyright 2013 Endless Mobile, Inc.
bin_SCRIPTS = \
- tools/eos-run-test \
tools/eos-application-manifest/eos-application-manifest \
tools/eos-json-extractor/eos-json-extractor \
$(NULL)
diff --git a/tools/eos-run-test.in b/tools/eos-run-test.in
deleted file mode 100644
index d58bd5e..0000000
--- a/tools/eos-run-test.in
+++ /dev/null
@@ -1,147 +0,0 @@
-#!/usr/bin/env gjs
-const Format = imports.format;
-const Gio = imports.gi.Gio;
-const GLib = imports.gi.GLib;
-const JsUnit = imports.jsUnit;
-const Lang = imports.lang;
-const System = imports.system;
-
-String.prototype.format = Format.format;
-
-const PACKAGE_VERSION = '@PACKAGE_VERSION@';
-const JS_EXTENSION = '.js';
-
-/**
- * usage:
- *
- * Print command-line help message.
- */
-function usage() {
- print('Run a jsUnit unit test.\n');
- print('Usage: %s [options] TEST_FILES\n'.format(
- System.programInvocationName));
- print('Options:');
- print(' --help This help message');
- print(' --version Print version and exit');
- System.exit(0);
-}
-
-/**
- * version:
- *
- * Print command-line version output.
- */
-function version() {
- print('%s %s - Run jsUnit tests in a GJS source file'.format(
- System.programInvocationName, PACKAGE_VERSION));
- System.exit(0);
-}
-
-if(ARGV.indexOf('--help') != -1)
- usage();
-if(ARGV.indexOf('--version') != -1)
- version();
-if(ARGV.length < 1)
- usage();
-
-// Import JsUnit into global namespace
-if(!('assertEquals' in this))
- Lang.copyPublicProperties(JsUnit, this);
-
-function printError(error) {
- const SYNTAX_ERROR = '[object Error]';
- print(" " + error.message);
-
- if(error.stackTrace) {
- let stackTrace = error.stackTrace.split('\n');
- stackTrace.forEach(function(line) {
- if(line.length > 0){
- let prefix = ' --';
- if (error.type == SYNTAX_ERROR)
- prefix += '> ';
-
- print(prefix + line);
- }
- });
- }
-}
-
-function executeTest(testModule, test) {
- let result = { name: test };
- print("Running:", test);
- if(testModule.setUp) {
- testModule.setUp();
- }
- let startTime = GLib.get_real_time();
- try {
- testModule[test]();
- } catch(e) {
- print(" ERROR! >>>>>", test, "<<<<<");
-
- result.error = {
- type: Object.toString(e),
- message: e.message || e.jsUnitMessage,
- stackTrace: e.stack || e.stackTrace
- };
- printError(result.error);
- print('\n');
- } finally {
- if(testModule.tearDown) {
- testModule.tearDown();
- }
- }
-
- result.time = GLib.get_real_time() - startTime;
- return result;
-}
-
-function executeTestsForFile(file) {
- let testFile = file.get_basename();
- let testModuleName = testFile.slice(0, testFile.indexOf('.js'));
- print('File:', testFile);
- let oldSearchPath = imports.searchPath;
- imports.searchPath.unshift(file.get_parent().get_path());
- let testModule = imports[testModuleName];
- imports.searchPath = oldSearchPath;
-
- let results = [];
- Object.keys(testModule).forEach(function(key) {
- if(key.indexOf('test') === 0) {
- results.push(executeTest(testModule, key));
- }
- });
-
- return results;
-}
-
-function getTotalsFromResults(results) {
- let testsRunCount = 0;
- let testsFailedCount = 0;
- let testsPassedCount = 0;
-
- results.forEach(function(result) {
- if ('error' in result) {
- testsFailedCount++;
- }
- testsRunCount++;
- });
-
- testsPassedCount = testsRunCount - testsFailedCount;
- return {
- testsRunCount: testsRunCount,
- testsFailedCount: testsFailedCount,
- testsPassedCount: testsPassedCount
- };
-}
-
-let fileToTest = Gio.File.new_for_path(ARGV[0]);
-let results = executeTestsForFile(fileToTest);
-let totals = getTotalsFromResults(results);
-let totalsString = "Ran %d tests (%d Passed, %d Failed)".format(
- totals.testsRunCount, totals.testsPassedCount, totals.testsFailedCount);
-print(totalsString);
-
-if (totals.testsFailedCount > 0){
- printerr("Test(s) did not complete successfully");
- System.exit(1);
-}