[Dojo-interest] DOH with proper stack trace (debugAtAllCosts?)

20 views
Skip to first unread message

reesd

unread,
Jan 27, 2011, 10:15:31 PM1/27/11
to dojo-i...@mail.dojotoolkit.org

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
Dojo-i...@mail.dojotoolkit.org
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

reesd

unread,
Feb 1, 2011, 10:54:18 AM2/1/11
to dojo-i...@googlegroups.com
<Sorry if this is a duplicate for some. I posted on 1/27 through nabble at http://dojotoolkit.org/community, but I think I wasn't subscribed to mailing list yet so it didn't make it to the mailing list (I don't see it in the archive).>


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 (described below). Anyone have any suggestions or experience on how to get DOH to work with debugAtAllCosts? Or is it a bad idea for some reason I am missing? The inability to see the line numbers and inability to debug is kind of killing my ability to do "test first development".

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 an explicit <script> tag for doh.runner like the following
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.

I have tried putting a addOnLoad around the test runner code also, with the same results (no tests). I suspect I am not properly refactoring runner.html and possibly dealing with an assumption in doh.runner about load approach (at least in 1.5.0).

Any thoughts or lessons learned someone could share?

Thanks,
dave

Bill Keese

unread,
Feb 2, 2011, 4:36:17 AM2/2/11
to dojo-i...@mail.dojotoolkit.org
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.

reesd

unread,
Feb 5, 2011, 11:57:21 PM2/5/11
to dojo-i...@mail.dojotoolkit.org

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
--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/DOH-with-proper-stack-trace-debugAtAllCosts-tp2365333p2435666.html

reesd

unread,
Feb 6, 2011, 12:26:03 AM2/6/11
to dojo-i...@mail.dojotoolkit.org

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

--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/DOH-with-proper-stack-trace-debugAtAllCosts-tp2365333p2435755.html

reesd

unread,
Feb 6, 2011, 2:45:23 PM2/6/11
to dojo-i...@mail.dojotoolkit.org

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.
--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/DOH-with-proper-stack-trace-debugAtAllCosts-tp2365333p2439030.html

reesd

unread,
Feb 6, 2011, 3:16:01 PM2/6/11
to dojo-i...@mail.dojotoolkit.org

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
--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/DOH-with-proper-stack-trace-debugAtAllCosts-tp2365333p2439195.html

sam foster

unread,
Feb 7, 2011, 9:19:41 AM2/7/11
to dojo-i...@mail.dojotoolkit.org
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

reesd

unread,
Feb 8, 2011, 8:53:11 AM2/8/11
to dojo-i...@googlegroups.com, dojo-i...@mail.dojotoolkit.org
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.
Reply all
Reply to author
Forward
0 new messages