testing actionpack (for patch)

Sorry if this is posted twice, but this didn't seem to get through when
I first tried 6 hours ago. I'll try once more.

Hello,

Can anybody help me with the problem outlined below? I posted last
week and still haven't received a response. I'd think at least a core
dev would have some insight on this issue.

I've tried asking in the IRC channel as well, but haven't received a
response there either.

I'd really like to submit this patch of mine, but without being able
to run the tests, I'm not really eager to submit it.

I'll try IRC again if I still get nothing from the list.

Thanks,
Andrew

I haven’t seen this error. If a test failure is not relevant to your patch, just submit it as-is.

jeremy

All I've done is check rails edge out, make my modifications and am
attempting to run the tests from the actionpack directory, but get the
error I've mentioned. So I'm not sure how to run my tests at all to
make sure things are working as they should.

In the directory "rails/actionpack" is where I'm trying to run one of
the following commands...

rake test_action_pack
rake test
ruby test/templates/date_helper_test.rb

All produce the error.

I suppose I could try to find the code that this dependency is coming
from and comment it out for the time being to get my tests to run...
if possible.

Andrew

Actually if I freeze my app to edge using "rake rails:freeze:edge" and
then run script/server I get the exact same error.

Has anybody seen anything similar?

Here's the error again (for those that missed it)...

./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:248:in
`load_missing_constant': uninitialized constant
ActionView::Helpers::JavaScriptHelper::PrototypeHelper (NameError)

I'm confused.

Actually if I freeze my app to edge using "rake rails:freeze:edge" and
then run script/server I get the exact same error.

Has anybody seen anything similar?

Here's the error again (for those that missed it)...

./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:248:in
`load_missing_constant': uninitialized constant
ActionView::Helpers::JavaScriptHelper::PrototypeHelper (NameError)

I'm confused.

This works fine for me, If you roll back your changes does it still
happen? Does your test app have any plugins installed?

I didn't incorporate my changes into the frozen edge, so that's not the problem.

I guess I'll assume my enivronment is screwed up somehow when it comes
to using edge if others are having no issues.

I'll try creating a clean app and then try the freeze again, otherwise
I'll just hang on to my patch changes for a while until I get things
working with a later version.

The thing is, when I'm attempting to run the tests directly from the
svn repo it causes problems, so I'm having issues outside the context
of an app anway.

Do installed gems (or any other environment configurations) have any
affect on a checked out version (from the svn repo) of edge?

Thanks

I'm seeing this error on two of my three production boxes (which are
all identical, so it's confusing as to why it's only happening on two
of them). I dug into the helpers a little and found that the problem
is with a couple of the helpers (found in actionpack/lib/action_view/
helpers).

Specifically, at the top of javascript_helper.rb, there is a require
of prototype_helper, and at the top of prototype_helper.rb, there is
a require of javascript_helper. This seems like it should work, but
it's throwing the error you mention below when I try to start
mongrel. I've been able to hack, er, work around it by replacing one
of the requires with the actual file content. Here's what I'm doing
step-by-step:

1) copy the contents of prototype_helper.rb

2) remove the "require ... prototype_helper" line from the top of
javascript_helper.rb (line 2)

3) paste the prototype helper content copied in step one in place of
the line you just removed

4) remove the "require ... javascript_helper" line from the content
you just pasted in.

I suspect this is related to the new dependency code, but I'm not
sure. I would like to submit a bug report, but I'm not sure how to
construct a unit test for it, since it works fine on one box and
fails on the other two (identical) boxes. If it matters, I'm running
this on Fedora Core 5 / x86_64 machines, and we're frozen at rev.
4883 of rails.

I was seeing similar things too when poking around the files.

Thanks for the information, I'll try it out and see if I can resolve
the problem locally.

Andrew

Its really wierd, I have not met the problem (and still doesn’t) on my main machine. But my new box experiences the problem. Both machines compiles ruby from tarball.

The problem is with cyclic dependencies between prototype_helper.rb (which requires javascript_helper.rb) and javascript_helper.rb (which requires prototype_helper.rb AND expects PrototypeHelper defined)

If prototype_helper.rb(1) is loaded first, it will

  • load javascript_helper.rb(2), which will…
  • load prototype_helper.rb(3) which will…
  • skip reloading javascript_helper.rb (since #2 is ongoing) and…
  • proceed with the rest of the code to define PrototypeHelper…
  • exits #2
  • proceeds with #2 which expects PrototypeHelper (it is defined by #3)…
  • exits #2
  • proceeds with #1 which redefines PrototypeHelper (since its defined already) with the same code
  • everything proceeds smoothly
    If javascript_helper.rb(1) is loaded first, it will
  • load prototype_helper.rb(2) which will…
  • load javascript_helper.rb(3) which will…
  • skip reloading of prototype_helper.rb (since #2 is ongoing) and …
  • proceed with the rest of the code which requires PrototypeHelper defined - but its not done by #2 yet
  • so it all dies
    Makes me wonder how it worked in the machines that does?

Not sure what’s the best solution, submitted a patch to move the require statement AFTER defining PrototypeHelper. Or we should just remove the require statement all together.

In the meantime, to use edge, I added this line to the top of my config/environment.rb
require ‘action_view/helpers/prototype_helper’

Missing anything?

This is actually related to a bigger issue that the files (*helper.rb) are not loaded in a consistent order. Hence the unpredictable nature of problems.

Patch submitted
.

Nice work. Thanks for looking into this. Now I know I'm not crazy.

Makes sense – we’ve run into issues before where load order varied between platforms and caused inconsistent behavior. I wonder if we should monkeypatch Dir.foreach to be sorted and fix this at a higher level? There are probably other places in the framework where inconsistent load order could (does?) induce weirdness. Off the top of my head, I can’t think of any bad side effects of forcing consistent ordering across the board for Dir.foreach… Thoughts?

Solomon White wrote:

Makes sense -- we've run into issues before where load order varied between platforms and caused inconsistent behavior. I wonder if we should monkeypatch Dir.foreach to be sorted and fix this at a higher level? There are probably other places in the framework where inconsistent load order could (does?) induce weirdness. Off the top of my head, I can't think of any bad side effects of forcing consistent ordering across the board for Dir.foreach... Thoughts?

I think that if there is a program somewhere that relied on Dir.foreach having a particular order, it would break anyway if moved across platforms, so breaking it by doing this will just make it break faster.

Why not wrap Dir.foreach in a custom method or something and do the
ordering in that? ie. get all the files, sort the array, return it.

That would be fine, but we'd also need to go through the Rails
framework and replace all the foreach calls with our new custom
method. And train people to use it in the future instead of the
stock foreach.