[seed] Fix tests when builddir != srcdir



commit 369fda3d5f885dfa51b5945864554bc92cb9dfa8
Author: Mathieu Duponchelle <mathieu duponchelle opencreed com>
Date:   Fri Sep 16 02:23:25 2016 +0200

    Fix tests when builddir != srcdir
    
    https://bugzilla.gnome.org/show_bug.cgi?id=771510

 configure.ac                                       |    3 ++
 jsextensions/Seed.js.in                            |   24 ++++++++++++++++++++
 tests/c/Makefile.am                                |    6 +++++
 tests/javascript/Makefile.am                       |    5 ++-
 tests/javascript/include.js                        |    2 +-
 tests/javascript/included.js.in                    |    3 ++
 ...odules-noasserts.js => modules-noasserts.js.in} |    0
 ...st-noasserts.js => syntax-test-noasserts.js.in} |    0
 8 files changed, 40 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8d68e2d..8c0bae2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -487,6 +487,9 @@ src/Makefile
 jsextensions/Makefile
 tests/Makefile
 tests/javascript/Makefile
+tests/javascript/included.js
+tests/javascript/syntax-test-noasserts.js
+tests/javascript/modules-noasserts.js
 tests/javascript/gtypes/Makefile
 tests/javascript/signals/Makefile
 tests/javascript/structs/Makefile
diff --git a/jsextensions/Seed.js.in b/jsextensions/Seed.js.in
index 0fe9deb..3c66fa2 100644
--- a/jsextensions/Seed.js.in
+++ b/jsextensions/Seed.js.in
@@ -34,6 +34,30 @@ if(!imports.searchPath || (imports.searchPath.length == 0))
        }
 
        imports.searchPath.unshift(".");
+
+       var user_paths = GLib.getenv("SEED_MODULE_PATH");
+       if (user_paths != null) {
+               var i = null;
+
+               user_paths = user_paths.split(":");
+               for (i=0; i<user_paths.length; i++) {
+                       try
+                       {
+                               var module_path = user_paths[i];
+
+                               if(!GLib.path_is_absolute(module_path)) {
+                                       module_path = GLib.build_filenamev([GLib.get_current_dir(),
+                                                                           module_path]);
+                               }
+                               if (module_path && module_path != "")
+                                       imports.searchPath.unshift(module_path);
+                       }
+                       catch(e)
+                       {
+                               print(imports.JSON.stringify(e));
+                       }
+               }
+       }
 }
 
 // TODO: This will work, but won't work if not installed
diff --git a/tests/c/Makefile.am b/tests/c/Makefile.am
index 954c6ea..b9c9d25 100644
--- a/tests/c/Makefile.am
+++ b/tests/c/Makefile.am
@@ -1,3 +1,9 @@
+TESTS_ENVIRONMENT = \
+       GI_TYPELIB_PATH=$(top_builddir)/libgjs-private:$$GI_TYPELIB_PATH  \
+       LD_LIBRARY_PATH=$(top_builddir)/libgjs-private/.libs:$$LD_LIBRARY_PATH \
+       SEED_MODULE_PATH=$(top_srcdir)/modules:$$SEED_MODULE_PATH \
+       $(NULL)
+
 noinst_PROGRAMS = test
 
 TESTS = test
diff --git a/tests/javascript/Makefile.am b/tests/javascript/Makefile.am
index 1b21fce..7a0257f 100644
--- a/tests/javascript/Makefile.am
+++ b/tests/javascript/Makefile.am
@@ -21,13 +21,14 @@ EXTRA_DIST = \
     gobject-scope.js \
     gvalue-argument.js \
     include.js \
+    included.js.in \
     include-syntax.js \
     introspect.js \
     json-constructor.js \
     json.js \
     list-test.js \
     modules.js \
-    modules-noasserts.js \
+    modules-noasserts.js.in \
     native-closure-exception.js \
     native-closure.js \
     object-info.js \
@@ -37,7 +38,7 @@ EXTRA_DIST = \
     quit.js \
     sqlite.js \
     syntax-test.js \
-    syntax-test-noasserts.js \
+    syntax-test-noasserts.js.in \
     type-conversion.js \
     testsuite.js
 
diff --git a/tests/javascript/include.js b/tests/javascript/include.js
index ccc71de..ea74a37 100755
--- a/tests/javascript/include.js
+++ b/tests/javascript/include.js
@@ -1,3 +1,3 @@
 #!/usr/bin/env seed
 
-Seed.include("json.js");
+Seed.include("included.js");
diff --git a/tests/javascript/included.js.in b/tests/javascript/included.js.in
new file mode 100644
index 0000000..1729677
--- /dev/null
+++ b/tests/javascript/included.js.in
@@ -0,0 +1,3 @@
+#!/usr/bin/env seed
+
+included_varaiable = 42;
diff --git a/tests/javascript/modules-noasserts.js b/tests/javascript/modules-noasserts.js.in
similarity index 100%
rename from tests/javascript/modules-noasserts.js
rename to tests/javascript/modules-noasserts.js.in
diff --git a/tests/javascript/syntax-test-noasserts.js b/tests/javascript/syntax-test-noasserts.js.in
similarity index 100%
rename from tests/javascript/syntax-test-noasserts.js
rename to tests/javascript/syntax-test-noasserts.js.in


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]