Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Bug 691865 No runtime search #249

Merged
merged 37 commits into from Oct 26, 2011
Merged

Conversation

warner
Copy link
Contributor

@warner warner commented Oct 25, 2011

@Gozala : this is the cleanup required for your #247 pull request. All tests pass, but I deleted test-securable-module (and the whole tests/interoperablejs-read-only suite) (neither of which passed after my patch) in anticipation of your loader changes.

This branch removes the runtime module search, by doing the following:

linker:

  • scan all unit test files, just like normal lib/ files
  • add all tests as fake dependencies to "api-utils/lib/unit-test-finder"
  • add test-harness/lib/run-tests to the manifest (which includes unit-test-finder), to include all tests in the XPI and the manifest
  • add a list of tests to harness-options.json, in .allTestFiles
  • change unit-test-finder to use that list, instead of scanning the source tree
  • change the way 'cfx testall' works, to remove the fake 'testpkgs' package
  • pass the entry-point URI (either main.js or test-harness/lib/run-tests.js) in harness-options.json as mainURI

loader:

  • use mainURI instead of searching for main
  • remove runtime search
  • load helper modules by URI instead of by search
  • add "packaging" module, with myURI and harnessOptions
  • add requireURI() method for entrypoint and helper modules

tests:

  • pass myURI into createSandboxedLoader(), so it can use the manifest correctly

Some of this is a bit ugly, but will be cleaned up by Irakli's new loader once it lands, which should be shortly after this one lands.

also:
 * locate all test modules are manifest-generation time, add them as
   artificial dependencies of api-utils/unit-test-finder
 * stop including "chrome" as a dependency of each test case
 * handle "all-test-modules" pseudomodule
 * handle "packaging" pseudomodule (with data.basePath= URI of caller)
obtained with require("packaging").myURI
* add "packaging" pseudomodule
* add non-searching requireURI(uri), for entrypoint and loader
* pass basePath into various places
* components/harness.js: use loader.requireURI() for entrypoint
hand it to the new loader so searches have a starting point. Also pass in
"packaging" so it can get a copy of the manifest.

Also includes some debug messages.
Previously test_all_packages() built a fake package that depended upon
everything in the packages/ directory. Now it simply runs 'cfx test' over
each package, just like test_all_examples() does.

This should remove the need for some special-purpose code in, IIRC, test-self
and maybe some other "magic" modules. I'm not sure how it might change
overall behavior. I do know that packages/development-mode has no tests, so
either we need to skip that one or tolerate the 0-of-0 case (and not think
that it means failure).
…e search

And remove .dirs from the arguments passed into findAndRunTests, removing one
consumer of options.rootPaths . Some day we'll be able to get rid of that.

All tests pass.
Irakli tells me the functionality tested by this module is no longer relevant
to his new loader, so rather than try to rewrite it to avoid doing a runtime
search, I'm just getting rid of it.

test-file.js is still relevant (it exercises the "file" module), but it was
using the old interoperablejs-read-only/ directory as a source of known
filenames. I changed it to use modules/ for that purpose instead.
if (!path)
throw new Error('Module "' + moduleName + '" not found');
moduleData = {uri: path};
throw new Error("NO SEARCH FOR YOU");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit I think error message can be better than this, like module foo has no privilege to load module bar.

@Gozala
Copy link
Contributor

Gozala commented Oct 26, 2011

I think it's ready to land! Only one nit.

@warner
Copy link
Contributor Author

warner commented Oct 26, 2011

I rearranged that part of the code to remove the error message entirely, and to make it more clear that "moduleData" is always passed in.

warner pushed a commit that referenced this pull request Oct 26, 2011
Bug 691865: stop doing runtime module search. r=irakli
@warner warner merged commit cc2d508 into mozilla:master Oct 26, 2011
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants