Ensure order of globbed files in task helpers #205

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@mark-rushakoff

The docs for Dir.glob state:

Note that case sensitivity depends on your system (so File::FNM_CASEFOLD is ignored), as does the order in which the results are returned.

So when I ran rake:spec on Ubuntu 11.10 with an ext3 filesystem, the source files in my runner.html were in a seemingly arbitrary order:

<!-- include source files here... -->
<script type="text/javascript" src=".././src/html/HtmlReporterHelpers.js"></script>
<script type="text/javascript" src=".././src/html/TrivialReporter.js"></script>
<script type="text/javascript" src=".././src/html/SuiteView.js"></script>
<script type="text/javascript" src=".././src/html/HtmlReporterHelpers.js"></script>
<script type="text/javascript" src=".././src/html/ReporterView.js"></script>
<script type="text/javascript" src=".././src/html/HtmlReporter.js"></script>
<script type="text/javascript" src=".././src/html/SpecView.js"></script>
<script type="text/javascript" src=".././src/console/ConsoleReporter.js"></script>
<!-- include spec files here... -->

This resulted in the following runtime errors:

SuiteView.js:1 Uncaught TypeError: Cannot set property 'SuiteView' of undefined
ReporterView.js:1 Uncaught TypeError: Cannot set property 'ReporterView' of undefined
HtmlReporter.js:22 Uncaught TypeError: undefined is not a function

After applying this fix, my script sources were the same as the runner.html that is currently checked in to the upstream master branch:

<!-- include source files here... -->
<script type="text/javascript" src=".././src/html/HtmlReporterHelpers.js"></script>
<script type="text/javascript" src=".././src/html/HtmlReporter.js"></script>
<script type="text/javascript" src=".././src/html/HtmlReporterHelpers.js"></script>
<script type="text/javascript" src=".././src/html/ReporterView.js"></script>
<script type="text/javascript" src=".././src/html/SpecView.js"></script>
<script type="text/javascript" src=".././src/html/SuiteView.js"></script>
<script type="text/javascript" src=".././src/html/TrivialReporter.js"></script>
<script type="text/javascript" src=".././src/console/ConsoleReporter.js"></script>
<!-- include spec files here... -->

And of course the browser tests now pass in Chromium on my machine. The node tests pass as well.

There are still several places where I didn't sort Dir.glob:

  • jasmine-core.gemspec and lib/jasmine-core.rb because I didn't have a way to test either of them
  • tasks/build_dist.rb which globbed a single file without wildcards: Dir.glob('src/version.js')
  • tasks/spec.rb which was just globbing files for the purpose of counting specs
@infews

Mark - thanks for digging this out. I've refactored this code heavily for 1.2 - in changing all the dev tasks to thor so this pull request is about to be invalid. However, here's the Tracker bug: https://www.pivotaltracker.com/story/show/26839647 and I'll let you know when it's pushed so you can verify.

@infews

This is now fixed on HEAD of master. Moved the list to Ruby and made the concat completely explicit.

@infews infews closed this Apr 1, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment