From b47df8a7262001d371369a6b5d496a708eed0252 Mon Sep 17 00:00:00 2001 From: "jwalden%mit.edu" Date: Wed, 31 Jan 2007 07:22:12 +0000 Subject: [PATCH] Final try at bug 351968 -- make relative topsrcdirs work, fixing the last build errors. Because xpcshell tests are fragile, this commit intentionally breaks a test so that I can verify correctness; I'll remove the break when I verify the fix works correctly (via broken test error messages). --- config/rules.mk | 11 ++--------- content/test/unit/head_content.js | 4 +--- intl/uconv/tests/unit/test_charset_conversion.js | 4 +--- modules/libjar/test/unit/test_bug333423.js | 4 +--- .../test/httpserver/test/test_registerdirectory.js | 9 +++++---- .../test/httpserver/test/test_setindexhandler.js | 4 +--- tools/test-harness/xpcshell-simple/head.js | 13 ++++++++++++- 7 files changed, 23 insertions(+), 26 deletions(-) diff --git a/config/rules.mk b/config/rules.mk index 9241e99884e..9ad57fec054 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -1820,17 +1820,10 @@ libs:: $(DEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir; \ done -# topsrcdir can be relative, but since we need NATIVE_TOPSRCDIR to -# be absolute (it's passed to tests for use in getting access to -# files), we need to convert it. -# -# XXX is this the right way to do it? -_ABS_TOPSRCDIR := `realpath $(topsrcdir)` - ifdef CYGWIN_WRAPPER -NATIVE_TOPSRCDIR := `cygpath -wa $(_ABS_TOPSRCDIR)` +NATIVE_TOPSRCDIR := `cygpath -wa $(topsrcdir)` else -NATIVE_TOPSRCDIR := $(_ABS_TOPSRCDIR) +NATIVE_TOPSRCDIR := $(topsrcdir) endif # CYGWIN_WRAPPER # Test execution diff --git a/content/test/unit/head_content.js b/content/test/unit/head_content.js index 5396d869d27..085f7ff789e 100644 --- a/content/test/unit/head_content.js +++ b/content/test/unit/head_content.js @@ -66,9 +66,7 @@ var __testsDirectory = null; function ParseFile(file) { if (typeof(file) == "string") { if (!__testsDirectory) { - __testsDirectory = C["@mozilla.org/file/local;1"] - .createInstance(I.nsILocalFile); - __testsDirectory.initWithPath(do_get_topsrcdir()); + __testsDirectory = do_get_topsrcdir(); __testsDirectory.append("content"); __testsDirectory.append("test"); __testsDirectory.append("unit"); diff --git a/intl/uconv/tests/unit/test_charset_conversion.js b/intl/uconv/tests/unit/test_charset_conversion.js index 44a182e7dfc..7570e7c3bd2 100644 --- a/intl/uconv/tests/unit/test_charset_conversion.js +++ b/intl/uconv/tests/unit/test_charset_conversion.js @@ -31,9 +31,7 @@ function run_test() "nsIConverterInputStream", "init"); - dataDir = Cc["@mozilla.org/file/local;1"] - .getService(Ci.nsILocalFile); - dataDir.initWithPath(do_get_topsrcdir()); + dataDir = do_get_topsrcdir(); dataDir.append("intl"); dataDir.append("uconv"); dataDir.append("tests"); diff --git a/modules/libjar/test/unit/test_bug333423.js b/modules/libjar/test/unit/test_bug333423.js index ad24649abfd..a2abe836031 100644 --- a/modules/libjar/test/unit/test_bug333423.js +++ b/modules/libjar/test/unit/test_bug333423.js @@ -44,9 +44,7 @@ function run_test() { const Ci = Components.interfaces; // the build script have created the zip we can test on in the current dir. - var file = Cc["@mozilla.org/file/local;1"] - .createInstance(Ci.nsILocalFile); - file.initWithPath(do_get_topsrcdir()); + var file = do_get_topsrcdir(); file.append("modules"); file.append("libjar"); file.append("test"); diff --git a/netwerk/test/httpserver/test/test_registerdirectory.js b/netwerk/test/httpserver/test/test_registerdirectory.js index cb9d67a487c..018a18ec943 100644 --- a/netwerk/test/httpserver/test/test_registerdirectory.js +++ b/netwerk/test/httpserver/test/test_registerdirectory.js @@ -286,10 +286,11 @@ var testsDirectory; function run_test() { - testsDirectory = Cc["@mozilla.org/file/local;1"] - .createInstance(Ci.nsILocalFile); -dumpn("*** topsrcdir: " + do_get_topsrcdir()); - testsDirectory.initWithPath(do_get_topsrcdir()); + testsDirectory = do_get_topsrcdir(); +dumpn("*** topsrcdir: " + testsDirectory.path); +dumpn("*** normalized: " + (v=testsDirectory.clone(),v.normalize(),v.path)); +do_throw("xpcshell tests don't timeout -- doing this to verify fix, " + + "then will remove after verifying"); testsDirectory.append("netwerk"); testsDirectory.append("test"); testsDirectory.append("httpserver"); diff --git a/netwerk/test/httpserver/test/test_setindexhandler.js b/netwerk/test/httpserver/test/test_setindexhandler.js index 00a5e282d76..4dce4be1494 100644 --- a/netwerk/test/httpserver/test/test_setindexhandler.js +++ b/netwerk/test/httpserver/test/test_setindexhandler.js @@ -104,9 +104,7 @@ var srv, serverBasePath; function run_test() { srv = createServer(); - serverBasePath = Cc["@mozilla.org/file/local;1"] - .createInstance(Ci.nsILocalFile); - serverBasePath.initWithPath(do_get_topsrcdir()); + serverBasePath = do_get_topsrcdir(); serverBasePath.append("netwerk"); serverBasePath.append("test"); serverBasePath.append("httpserver"); diff --git a/tools/test-harness/xpcshell-simple/head.js b/tools/test-harness/xpcshell-simple/head.js index faeb80f25eb..f36a331e215 100644 --- a/tools/test-harness/xpcshell-simple/head.js +++ b/tools/test-harness/xpcshell-simple/head.js @@ -142,5 +142,16 @@ function do_import_script(topsrcdirRelativePath) { } function do_get_topsrcdir() { - return environment["NATIVE_TOPSRCDIR"]; + try { + var lf = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + lf.initWithPath(environment["NATIVE_TOPSRCDIR"]); + } catch (e) { + // relative topsrcdir + lf = Components.classes["@mozilla.org/file/directory_service;1"] + .getService(Components.interfaces.nsIProperties) + .get("CurWorkD", Ci.nsILocalFile); + lf.appendRelativePath(environment["NATIVE_TOPSRCDIR"]); + } + return lf; }