Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
simpletest.module
Priority:
Major
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
12 May 2015 at 16:26 UTC
Updated:
15 Jul 2015 at 10:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
catchMakes sense to me.
Comment #2
scott weston commentedIn the current function (found in core/modules/simpletest/src/TestBase.php), an ampersand is returned in randomString generated strings where the requested length is greater than 2. Will the greater than ('>') need to be added to all strings or just to those greater than 2 (similar to the ampersand)?
Comment #3
fabianx commentedJust for those strings greater than 2 should be fine.
Comment #4
scott weston commentedHere's a patch for this. Adding a greater than ('>') into the pseudo-random string generated by randomString in core/modules/simpletest/src/TestBase.php. (This is my first patch, so I probably did not follow all the protocols. Tell me what I did wrong and I'm happy to adjust things).
Comment #5
fabianx commentedLooks good.
Comment #6
cilefen commentedWhat if a test really needs a random string? I would feel better if the function were renamed pseudorandomTestString() or similar in order to convey there is a difference.
Comment #7
fabianx commentedIt is still random, just has less entropy ...
Comment #8
xjm+1 for this change in general for the same reasons as in the original issue. However, we need test coverage.
I also wonder if we should randomize the positions of these two special characters more, rather than sticking them together always? To @cilefen's point.
Comment #9
imiksuWriting tests.
Comment #10
imiksuIt looks like this already gets tested?
\Drupal\Tests\simpletest\Unit\TestBaseTest::testRandomStringHowever, as @xjm suggested, I wrapped ”almost-random" string with
str_shuffle()making it more random :)Comment #12
fabianx commentedWe should test for the new character as well here?
Comment #13
scott weston commentedPatch from #4 and adding a test for Greater Than (">") on strings longer than 2 characters.
Comment #14
scott weston commentedComment #15
scott weston commentedComment #16
dawehnerThe patch looks pretty great!!
:( < 80 chars
Comment #17
scott weston commentedWhoops. Good catch on the super long line!
I tweaked that text to be less than 80 chars per line.
Comment #18
dawehnertrailing whitespace :( Feel free to fix that now or let the committer deal with it
Comment #19
alexpotti'm concerned about the fact the we're severely limiting the number of possibilities for 3 letter random strings. Random strings are guaranteed to be be unique. Maybe we should increase this form 2 to 3. There is only one use of
$this->randomString(3)in the code base inDrupal\views\Tests\GlossaryTest- I don't see any problems with removing the 3 from the method call there.errant space on the end of the line
Comment #20
scott weston commented@alexpott: To clarify your first point in #19... Are you asking for the insertion of '>&' to happen on generated strings that are greater than 3 characters in length (so when $length is 1, 2, or 3, > and & aren't inserted)?
Comment #21
dawehnerAdding a related issue which adds such a trait: #2304461: KernelTestBaseTNG™
Comment #22
imiksuI think that is covered by the first three lines of
\Drupal\simpletest\TestBase::randomString:#19.2: Fixed
#19.3: I suggest to create separate issue if there's even an related issue (as @dawehner pointed out in #21). The original report about avoiding random test fails moves forward having such traits or not.
Comment #29
fabianx commentedBack to RTBC
Comment #30
alexpottNow we're adding both
&and>I think we need to raise this to 4.Comment #31
Cristian.Andrei commentedbumped $length to 4 instead of 3.
changed status.
Comment #32
imiksuWe need the full patch.
Comment #34
Cristian.Andrei commentedthe full patch + interdiff
Comment #36
imiksuWe need to change this test from ”greater than 2" to "greater than 3" and the comments too..
Comment #37
Cristian.Andrei commentedcreated a patch as per iMiksu's comments
Comment #41
fabianx commentedshould be 3 here as well then.
Comment #42
Cristian.Andrei commentedupdated comment
Comment #44
Cristian.Andrei commentedfirst try -> http://lastgif.com/gifs/1022.gif
Comment #45
fabianx commentedLets try again :). Looks great to me now.
Comment #46
catchCommitted/pushed to 8.0.x, thanks!