DOH with proper stack trace (debugAtAllCosts?)

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

DOH with proper stack trace (debugAtAllCosts?)

reesd
I'm interested in having my DOH errors show the actual file where the error is. By default everything is shown inside in bootstrap.js, so I have been looking at adding debugAtAllCosts to runner.html. But then I run into issues with it loading doh.runner.

Anyone have any suggestions on how to get DOH to work with debugAtAllCosts work, or is it just a bad idea?

Here is what I am seeing as I work on it with Firefox 3.6, FireBug, Dojo 1.5.0-src…

If I just add debugAtAllCosts to runner.html I get the following (as described in http://bugs.dojotoolkit.org/ticket/10443) in the console.
TypeError: dojo.hostenv is undefined
uncaught exception: Could not load cross-domain resources: doh.runner


If I change the dojo.require(“runner.js”) section to use a <script> tag like the following <i><script type='text/javascript' src='http://localhost:8080/dev/js/libs/dojo/dojo-release-1.5.0-src/util/doh/runner.js'></script>

then I get:
TypeError: availableFlatLocales is undefined
Error: Could not load 'dojo.number'; last tried './number.js'
Error: Could not load 'dojox.charting.plot2d.Pie'; last tried '../dojox/charting/plot2d/Pie.js'
Error: Could not load 'dojox.charting.Chart2D'; last tried '../dojox/charting/Chart2D.js'
uncaught exception: Could not load cross-domain resources: doh._browserRunner dojox.charting.Chart2D dojox.charting.plot2d.Pie dojo.number


If I then switch to 1.6.0b1-src, I get past all the errors above – but I have no tests shown in the browser.

Any thoughts?

Thanks,

dave
Reply | Threaded
Open this post in threaded view
|

Re: DOH with proper stack trace (debugAtAllCosts?)

Bill Keese-2
Hmm, you could try using the AMD loader (see http://docs.dojocampus.org/releasenotes/1.6#id10), although it won't be ready for prime-time until the 1.7 release, so it's somewhat DIY now.

On Fri, Jan 28, 2011 at 12:15 PM, reesd <[hidden email]> wrote:

I'm interested in having my DOH errors show the actual file where the error
is. By default everything is shown inside in bootstrap.js, so I have been
looking at adding debugAtAllCosts to runner.html. But then I run into issues
with it loading doh.runner.

Anyone have any suggestions on how to get DOH to work with debugAtAllCosts
work, or is it just a bad idea?

Here is what I am seeing as I work on it with Firefox 3.6, FireBug, Dojo
1.5.0-src…

If I just add debugAtAllCosts to runner.html I get the following (as
described in http://bugs.dojotoolkit.org/ticket/10443) in the console.
TypeError: dojo.hostenv is undefined
uncaught exception: Could not load cross-domain resources: doh.runner

If I change the dojo.require(“runner.js”) section to use a <script> tag like
the following
<script type='text/javascript'
src='http://localhost:8080/dev/js/libs/dojo/dojo-release-1.5.0-src/util/doh/runner.js'></script>

then I get:
TypeError: availableFlatLocales is undefined
Error: Could not load 'dojo.number'; last tried './number.js'
Error: Could not load 'dojox.charting.plot2d.Pie'; last tried
'../dojox/charting/plot2d/Pie.js'
Error: Could not load 'dojox.charting.Chart2D'; last tried
'../dojox/charting/Chart2D.js'
uncaught exception: Could not load cross-domain resources:
doh._browserRunner dojox.charting.Chart2D dojox.charting.plot2d.Pie
dojo.number


If I then switch to 1.6.0b1-src, I get past all the errors above – but I
have no tests shown in the browser.

Any thoughts?

Thanks,

dave

--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/DOH-with-proper-stack-trace-debugAtAllCosts-tp2365333p2365333.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: DOH with proper stack trace (debugAtAllCosts?)

reesd
Bill Keese-2 wrote
Hmm, you could try using the AMD loader (see
http://docs.dojocampus.org/releasenotes/1.6#id10), although it won't be
ready for prime-time until the 1.7 release, so it's somewhat DIY now.
Thanks for the tip Bill. The AMD stuff looks useful, I like that it will be consistent with CommonJS and RequireJS's approach. A common module approach across the main toolkits would be great. I'm hesitant to mess with it tills its more baked though. The work they are doing does seem to have fixed it for 1.6b2 (vs. 1.6b1) though - see my next post.

d
Reply | Threaded
Open this post in threaded view
|

Re: DOH with proper stack trace (debugAtAllCosts?)

reesd
In reply to this post by reesd
After way too much time (but some good Dojo XD learning) and with a little help from Chrome
(it's debugger seems to give more eval info than FireBug), I tracked down the issue and am happily testing my own code using debugAtAllCosts. Details below...


I had to change runner.js from to use requireIf rather than platformRequire. platformRequire breaks under XD as previous described in http://mail.dojotoolkit.org/pipermail/dojo-interest/2009-August/037840.html. I’ve created a ticket and attached a patch that fixes this for 1.5 - http://bugs.dojotoolkit.org/ticket/12260.


I also modified runner.html to allow adding debugAtAllCosts=true to the URL parameters to turn debugAtAllCosts on. Ticket and patch are at http://bugs.dojotoolkit.org/ticket/12261.


Unfortunately, in 1.5.0 I am unable to use debugAtAllCosts with the dojo tests themselves due to a 2nd problem with XD and requireLocalization. Several modules use a setUp pattern like the following:
var setUp = function(locale){
                return function(){
                        dojo.requireLocalization("tests","salutations",locale);
                }
        }

This will fail when XD loaded because the XD loader uses a regexp to pull and eval just the dojo.requireLocalization line. The eval fails since its missing the setUp closure that defines locale. The modules I have found using this pattern are tests.i18n, tests.date.locale, test.number.

I don’t understand the thinking behind XD behavior enough to know how to work around this and it seems fixed in 1.6b2 (the offending tests have been refactored). So I just created the ticket http://bugs.dojotoolkit.org/ticket/12262 and am leaving it there for now.

dave
Reply | Threaded
Open this post in threaded view
|

Re: DOH with proper stack trace (debugAtAllCosts?)

reesd
One more tweak, I have updated DOH's custom AssertionError to include the stack if it’s available. With Firebug/Chrome this means the test file’s link and line number are shown in the console.

Issue and patch (for 1.5 and 1.6) are at http://bugs.dojotoolkit.org/ticket/12263.
Reply | Threaded
Open this post in threaded view
|

Re: DOH with proper stack trace (debugAtAllCosts?)

reesd
In reply to this post by reesd
reesd wrote
Bill Keese-2 wrote
Hmm, you could try using the AMD loader (see
http://docs.dojocampus.org/releasenotes/1.6#id10), although it won't be
ready for prime-time until the 1.7 release, so it's somewhat DIY now.
Thanks for the tip Bill. The AMD stuff looks useful, I like that it will be consistent with CommonJS and RequireJS's approach. A common module approach across the main toolkits would be great. I'm hesitant to mess with it tills its more baked though. The work they are doing does seem to have fixed it for 1.6b2 (vs. 1.6b1) though - see my next post.
Actually, its not really "fixed" in 1.6b2. What is really happening is that 1.6b2 ignores the debugAtAllCosts (or at least the XD portion of it) since 1.6b2 doesn't support async loading. So I don't see the errors, but I also don't see filenames. The release notes say its possible to try and do it with RequireJS - but I don't think I want to mess with "unofficial" loaders for now. I think I'll wait till 1.6 has built-in async to try it out.

d
Reply | Threaded
Open this post in threaded view
|

Re: DOH with proper stack trace (debugAtAllCosts?)

Sam Foster
I normally use a "debugging build" for the problems you're describing.
This is a xdomain build, with optimize: "" (i.e. no
compression/minification). So a profile might look like:

dependencies = {
        copyTests: true,
        optimize: '',
        loader: 'xdomain',

        layers: [
        // ...your layers...
        ]
        // etc.
}

There's one more step - ensure your test_*.html files load the dojo.xd.js:

find $releaseDir -type f -print0 | xargs -0 grep -l 'dojo.js' | xargs
sed -i '' -e 's/dojo.js/dojo.xd.js/g'

..better still use .php or similar for your test pages so your path to
dojo.js can be easily parameterized.

This does 2 things:
1) It lets you test your build profile, and test your code's
observance of best practices wrt. async loading (i.e. use of
dojo.ready).
2) It lets you run your tests using the xdomain loader - which means
real script tags and proper stack traces with real line numbers.

hth
/Sam
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: DOH with proper stack trace (debugAtAllCosts?)

reesd
In reply to this post by reesd
I'll add that I also just found that I can get a lot of what I wanted by just making sure in Firebug that the "Decompile for eval() source" on the scripts drop-down is disabled (extensions.firebug.decompileEvals in about:config). When enabled I think this causes Firebug to overwrite the source with its own decompiled version and somehow lose the filename along the way as well. The functionality is being removed completely in 1.7a10 (see http://code.google.com/p/fbug/issues/detail?id=4035).

Or use Chrome, it's great with evals (but horrible with JS caching http://code.google.com/p/chromium/issues/detail?id=8742).

d

PS, Related stackoverflow on this at http://stackoverflow.com/questions/2627844/javascript-dojo-module-pattern-how-to-debug.

_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest