[dojo 1.7.0b] doh.runner does not work with registerModulePath or paths URL parameter

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[dojo 1.7.0b] doh.runner does not work with registerModulePath or paths URL parameter

tmahieu
Hello,

I'm trying to get my tests running with the dojo 1.7.0 beta, but I'm failing miserably.  My tests don't sit in a directory that is a sibling to dojo, so I need to pass a requireModulePath (which seems to be deprecated in favor of a 'paths' parameter) to runner.html.

Only, that doesn't seem to work, so I've been investigating a little and I think I've uncovered 2 issues:

First, runner.html parses the requireModulePath or paths parameter, but it doesn't use it anywhere.  I think it should be set in the config object, both in the sandbox or non sandbox case, like this:

config= {
  paths: paths,              
  deps:["dojo", "doh", "dojo/window"],
  callback:function(dojo, doh){
    dojo.ready(function(){
      fixHeight(dojo);
      doh.breakOnError= breakOnError;
      require(test);
      dojo.ready(doh, "run");
    });
  },
  async:async,
  isDebug:1
};

The paths property is not set in the config object in runner.html in 1.7.0b though.  If I add it, the path information is passed and processed to pathsMapProg as expected, and used in subsequent require calls.

However, my tests still didn't load because the path to the test module was still not correct:  Before a file is downloaded it's path seems to be compacted (compactPath function in dojo.js).  However, that function does not always update lastSegment when modifying the result array.  If I modify the function like this:

compactPath = function(path){
  var
    result= [],
    segment, lastSegment;
    path= path.split("/");
  while(path.length){
    segment= path.shift();
    if(segment==".." && result.length && lastSegment!=".."){
      result.pop();
      lastSegment = result.length ? result[result.length - 1] : null;        //ensure lastSegment always points to last element
    } else if(segment!=".") {
      result.push(lastSegment= segment);
    } // else ignore "."
  }
  return result.join("/");
},

If I test those modifications on a simple case, everything appears to be working, but maybe I'm missing things?  I'd register a trac ticket... but I guess I should sign the CLA first :)  (which reminds me... why haven't I done that yet :/).

thanks,

Tom
Reply | Threaded
Open this post in threaded view
|

Re: [dojo 1.7.0b] doh.runner does not work with registerModulePath or paths URL parameter

村上小白杨
This post has NOT been accepted by the mailing list yet.
I have a same problem。
Reply | Threaded
Open this post in threaded view
|

Re: [dojo 1.7.0b] doh.runner does not work with registerModulePath or paths URL parameter

村上小白杨
This post has NOT been accepted by the mailing list yet.
In reply to this post by tmahieu
in dojo 1.7.0 b2 . If you want use AMD  and  custom plugs with registerModule Path ,You need  require(["dojo/_base/loader"],function(dojo){
     dojo.registerModule("foo","../../foo")

     var foo =new  foo.custom.Object();
})