Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 10 years ago

#25781 closed enhancement (fixed)

QUnit should be testable on both compiled and minimized JS

Reported by: jorbin's profile jorbin Owned by: nacin's profile nacin
Milestone: 3.8 Priority: normal
Severity: normal Version: 3.8
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:

Description

Attachments (6)

25781.diff (1.7 KB) - added by jorbin 12 years ago.
25781.2.diff (1.4 KB) - added by jorbin 12 years ago.
25781.3.diff (1.4 KB) - added by jorbin 12 years ago.
25781.4.diff (1.2 KB) - added by kadamwhite 12 years ago.
Cleaned up spacing in 25781.3.diff, removed spaces-to-tabs conversion within a comment
25781.5.diff (1.0 KB) - added by nacin 11 years ago.
25781.6.diff (656 bytes) - added by jorbin 11 years ago.

Download all attachments as: .zip

Change History (23)

@jorbin
12 years ago

#1 @jorbin
12 years ago

  • Keywords has-patch added

To run, I've added the new task

grunt test:compiled

#2 @SergeyBiryukov
12 years ago

  • Component changed from Unit Tests to Build Tools

@jorbin
12 years ago

#3 @jorbin
12 years ago

The new patch uses copy and processContent instead of adding another dependency as suggested by Nacin.

#4 @ocean90
12 years ago

Re 25781.2.diff​: Seems like you have mixed tabs/whitespaces again. :)

#5 @jorbin
12 years ago

Thanks ocean90, at least I spelled everything correctly (I think).

25781.3.diff should fix that

@jorbin
12 years ago

@kadamwhite
12 years ago

Cleaned up spacing in 25781.3.diff, removed spaces-to-tabs conversion within a comment

#6 @kadamwhite
12 years ago

I edited 25781.3.diff to unify the whitespace style, and remove an edit to an unrelated comment that got caught in the spaces-to-tabs find/replace.

#7 @kadamwhite
12 years ago

  • Cc kadamwhite@… added

#8 @nacin
12 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 26063:

Add grunt qunit:compiled to run the QUnit tests on the compiled JS.

props jorbin, kadamwhite.
fixes #25781.

#9 @nacin
12 years ago

In 26064:

Add grunt phpunit which runs three tasks: phpunit, ajax tests, and phpunit as multisite.

You can also run grunt phpunit:default, grunt phpunit:ajax, and grunt phpunit:multisite separately.

grunt test now runs the qunit task (both compiled and uncompiled scripts) and the phpunit tasks.

props bpetty.
fixes #25854, see #25781.

#10 @jorbin
12 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

We should ignore the created compiled.html file so that after running the tests it doesn't show up in an svn status.

#11 @nacin
12 years ago

qunit:compiled runs clean:qunit when done, removing compiled.html. Of course, it is still possible for it to end up left behind.

#12 @jorbin
12 years ago

Hmm, mine was left before but reran it and this time it wasn't.

Overall, this seems like a bad idea as it makes it harder to test in browsers. Right now to test in browsers other than phantomjs, we can't run qunit:compiled, we need to run each command individually. If we have clean:qunit run before copy:qunit-compiled instead of after qunit, we gain this ability.

#13 @nacin
12 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 26108:

Don't remove the compiled.html QUnit file. Ignore it instead.

props jorbin.
fixes #25781.

@nacin
11 years ago

#14 @nacin
11 years ago

Now I remember why I did it the other way. The problem is if you run grunt qunit later, the compiled QUnit will be run, but it will be out of date.

Two options. One is grunt qunit:index and grunt qunit:compiled. Ideally, though, grunt qunit can be used just for qunit:index. This is not possible without a big hack and/or this enhancement upstream, as found by jorbin.

The second one is a bit of a hack, as attached as 25781.5.diff. Ideally, qunit:compiled runs it on the uncompiled as well, but I couldn't get it to execute qunit then set the config then re-execute qunit. It's a queueing system and things work async and such.

@jorbin
11 years ago

#15 @jorbin
11 years ago

A second hacky option as attached as 25781.6.diff is to use filter to filter out everything but index.html when we are running just qunit. Both my approach and Nacin's are far from perfect but I think keeping the hack in the config makes it a bit more readable. Either way, inline docs as to why we are doing it this way (or a link to the ticket) would be helpful.

#16 @adamsilverstein
11 years ago

  • Cc adamsilverstein@… added

#17 @boonebgorges
10 years ago

In 31344:

Use minified jquery-ui-core file during qunit:compiled Grunt task.

[30989] made jQuery UI Core a dependency for QUnit tests. This change did not
account for the fact that jQuery JS assets are minimized (and non-minimized
versions unavailable) when grunt copy populates the /build directory. To
ensure that QUnit tests pass when run during grunt qunit:compiled, we
manually fix the asset path to read 'core.min.js'.

See #25781.

Note: See TracTickets for help on using tickets.