Like it says on the tin.
Also converting the t() to format_string(). #500866: [META] remove t() from assert message
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | assertions.png | 87.26 KB | xjm |
| #16 | assert-1601202-16.patch | 28.15 KB | xjm |
| #16 | interdiff-16.txt | 3.88 KB | xjm |
| #14 | interdiff-11.txt | 4.85 KB | xjm |
| #11 | assert-1601202-11.patch | 24.27 KB | xjm |
Comments
Comment #1
xjmSo this a lot more than I thought it would be, but I couldn't think of another way to make it backportable.
I have not proofread this patch and I do not guarantee that it is not typo-ridden, incorrect, buggy, inconsistent, or on fire.
Help me testbot! You're my only hope.
Comment #2
xjmNORLY
Comment #3
xjmMissing format_string() here. That should fail prettily.
Missed a t() here, at least.
Comment #4
xjmWith issues in #3 fixed. Still haven't proofread thoroughly.
Comment #6
xjm(Edited.)
So, this is interesting.
where
$outand$expectedhave (as one might infer) a bunch of CJK unicode. In current core, that data is eliminated from the message, but with the patch, the DB chokes on this:PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xF0\xA0\x80\x80 \xF0...' for column 'message' at row 1: INSERT INTO {simpletest} (test_id, test_class, status, message, message_group, function, line, file) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => 7 [:db_insert_placeholder_1] => SearchTokenizerTestCase [:db_insert_placeholder_2] => pass [:db_insert_placeholder_3] => Value '一 盨 鿏 㐀 䃠 䶿 豈 切 ᄀ ᆀ ᇿ ꥠ ꥰ ힰ ퟘ ㄱ ㅠ ㆎ a n z a n z ヲ ᄀ ᅵ 가 쇘 ば ゟ ァ バ ヿ ㇰ ㇸ ㇿvar_export()blows up (recursing somehow?) when used on a database connection.#1 and #7 could potentially be fixed in the
assertionMessage()method, but the others are happening upstream in the assertions when trying to generate the default messages from the passed data. This would be easier to fix if assertions were objects.Comment #7
xjmSo this should eliminate some but not all of the failures.
Comment #9
xjmHmm. So #3 and #4 ran on 803 and got failures I can reproduce locally, but #7 ran on 654 and had different failures, including update path test stuff again. Retesting that.
Edit: So the "invalid multibyte sequence in argument" errors appear to happen on 803 but not 654.
Comment #10
xjmFailure #6 in my list is actually a bug in
assertResponse():The assertion accepts either an array or a string, but when passed an array, it tries to just print the array as a string argument.
Comment #11
xjmThe attached fixes #10 and also addresses the resource ID issue.
Comment #12
xjmComment #13
xjmExtra blank line there.
Comment #14
xjmNot sure where the interdiff went, but here it is.
Comment #15
xjmSee also #1601146: Allow custom assertion messages using predefined placeholders.
Comment #16
xjmWith workarounds for the handful of assertions in core that are not compatible with
var_export()because of circular references, plus the CJK thing which I couldn't figure out how to solve. Unfortunately I think the options are to either add a more sophisticated variable exporter, or not to backport this.Screenshot showing what some test results look like with this patch:

Comment #17
xjmComment #18
sunThe Database Connection test failures pretty much clarify why this cannot fly.
It is simply not possible to dump each and everything you pass into an assertion method.
Furthermore, I'm strongly opposed to the fundamental idea here. Developers need debugging details in case things go wrong. But not a mixture of poorly written custom assertion message novels, followed by an enforced variable dump garbage.
Almost all of the custom assertion messages are way too long in the first place. At some point, we started to write entire paragraphs of messages that try to explain the whole world and context. But an assertion message should state the expectation only.
Most tests were written before #582364: Add sensible defaults to SimpleTest assert messages landed, and I can only guess that the guidelines for how to write tests have never been updated accordingly.
So what this change effectively will do is to encourage people to continue to write and use completely bogus custom assertion messages, instead of writing better tests.
What we actually need is people to write proper tests. And we need to provide methods that are smart enough to support people to write proper tests.
Comment #19
sunThat screenshot nicely shows what I mean: Duplicate assertion messages all over the place.
Duplicate every single assertion message? No thanks. Why didn't the author use a proper assertion message in the first place?
Comment #23
mile23PHPUnit-based tests show you the assertion result and also the optional message, but not when you run them from run-tests.sh with --browser.
Calling this works-as-designed, but obviously re-open as desired.