Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
In developing a mechanism for contrib to run nightwatch.js tests, we discovered that when it attempts to write out the filename for the console logs, some directories are not created, because the testname can sometimes have '/''s in it.
Proposed resolution
Properly clean up the testname to convert spaces to dashes, and slashes to underscores.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#19 | 2974553-19.patch | 2.98 KB | Mixologic |
#19 | interdiff-2974553-17-19.txt | 1.01 KB | Mixologic |
#17 | 2974553-17.patch | 3.18 KB | justafish |
#16 | 2974553-16.patch | 3.17 KB | justafish |
#16 | 2974553-14.patch | 3.17 KB | justafish |
Comments
Comment #2
MixologicComment #3
MixologicAdding a blocked drupalci issue.
Comment #4
dawehnerThank you @mixologic for this patch! I'm curious why you haven't used
.replace(/[\s/]+/g, '-')
, am I missing something?Comment #5
GrandmaGlassesRopeMan@dawehner Nice one. I always forget about
[ ]
in regex.Comment #6
MixologicMostly because the slack convo sorta just ended up with that. just so the filename separated the module name from the test name. It could be just dashes too.
Tests_autodrop-JSTest_PASSED_Tue-May-22-2018-14:53:52-GMT+0000-(UTC)_console.json
vs
Tests-autodrop-JSTest_PASSED_Tue-May-22-2018-14:53:52-GMT+0000-(UTC)_console.json
maybe just the underscores separating the filenames from the status from date are all thats needed.
Your suggestion, I think, makes for simpler code vs whats there.
Comment #7
GrandmaGlassesRopeManSince
testName
is never reassigned, you can use const now.You could also replace
testName
here with(browser.currentTest.name || browser.currentTest.module)
Comment #8
MixologicFeedback incorporated, and a browserlog to browserLog fix incorporated.
Not interdiffing since its mostly the same size as the patch.
Comment #9
MixologicOne more bit of feedback incorporated : if we're cleaning strings of unwanted chars, lets do it all in the same style. Since we're cleaning both slashes and spaces out of one string, the split/join method seemed repetitive and verbose, so I opted to change the other to a regex replace.
The downside is regex readability, and "move all the things into one line". I'll leave this up to the JS maintainers to ultimately decide style choices - Im not informed enough in JS to decide one way or the other.
In any case this fix will unblock nightwatch testing in core and contrib. Right now nightwatch isnt producing any log data, so jenkins cant process the results, so although the tests are running, and you can see their results in the console log, drupalci cannot pass or fail the tests based on the outcome.
Comment #10
MixologicDang. I reversed my interdiff -> patch is going from splits to regexes.
Comment #11
justafish👍
Comment #12
alexpottCrediting @dawehner and @drpal for reviews on the issue and crediting @justafish for discussions that took place in #javascript Drupal slack.
Comment #13
alexpottThere's a JS style issue.
I think
/[\s\/]+/g
can be/[\s/]+/g
Comment #14
dawehnerOh yeah this one is always getting me. It just not obvious at all that you can skip the escaping.
Comment #15
MixologicI wasnt sure if we were linting those files yet. On the testbots we've got
So perhaps something needs to change in the .eslintignore?
Heres a patch that fixes the escaping.
Comment #16
justafishThis error wasn't getting picked up when running any of the scripts in package.json as it was only running on .es6.js files
Comment #17
justafishOops, will open up a follow up for the rogue || exit 0 stuff
Comment #18
GrandmaGlassesRopeManMakes sense to drop the
--ext
option here since we have this handled in the.eslintignore
file.We should either create the variables outside this string, or move
now
into this and avoid creating a variable. Either way is fine with me, but lets be consistent.Comment #19
MixologicAfter fighting for seconds with these changes, I finally have a fix.
Comment #20
MixologicI dont know how to use the tools I help maintain.
Comment #21
GrandmaGlassesRopeMan👍 Looks good to me.
Comment #22
alexpottCommitted 2e75397 and pushed to 8.6.x. Thanks!