Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better test failure with non-ASCII characters #6007

Merged
merged 4 commits into from
Mar 18, 2024

Conversation

MichaelChirico
Copy link
Member

Should help with situations like #5995 where it's hard to figure out from CI output alone what the issue might be. Byte representation will always be the "truest" way to look at why string comparison fails in a platform-robust way, in my experience.

Tested manually:

test(9999, '\u1234', 'abc')
test(99999, '\u1234', '\u2345')
test(999999, 'abc', '\u1234')
test(9999999, '\u1234', output='abc')
test(99999999, '\u1234', output='\u2345')
test(999999999, 'abc', output='\u1234')

with output:

Test 9999 ran without errors but failed check that x equals y:
> x = "ሴ" 
First 1 of 1 (type 'character'): 
[1] "ሴ"
Non-ASCII string detected, raw representation:
[[1]]
[1] e1 88 b4

> y = "abc" 
First 1 of 1 (type 'character'): 
[1] "abc"
1 string mismatch
Test 99999 ran without errors but failed check that x equals y:
> x = "ሴ" 
First 1 of 1 (type 'character'): 
[1] "ሴ"
Non-ASCII string detected, raw representation:
[[1]]
[1] e1 88 b4

> y = "⍅" 
First 1 of 1 (type 'character'): 
[1] "⍅"
Non-ASCII string detected, raw representation:
[[1]]
[1] e2 8d 85

1 string mismatch
Test 999999 ran without errors but failed check that x equals y:
> x = "abc" 
First 1 of 1 (type 'character'): 
[1] "abc"
> y = "ሴ" 
First 1 of 1 (type 'character'): 
[1] "ሴ"
Non-ASCII string detected, raw representation:
[[1]]
[1] e1 88 b4

1 string mismatch
Test 9999999 did not produce correct output:
Expected: <<abc>>
Observed: <<[1] "ሴ">>
Expected (raw): <<61 62 63>>
Observed (raw): <<5b 31 5d 20 22 e1 88 b4 22>>
Test 99999999 did not produce correct output:
Expected: <<⍅>>
Observed: <<[1] "ሴ">>
Expected (raw): <<e2 8d 85>>
Observed (raw): <<5b 31 5d 20 22 e1 88 b4 22>>
Test 1e+09 did not produce correct output:
Expected: <<ሴ>>
Observed: <<[1] "abc">>
Expected (raw): <<e1 88 b4>>
Observed (raw): <<5b 31 5d 20 22 61 62 63 22>>

Copy link

codecov bot commented Mar 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.50%. Comparing base (1fb3c75) to head (db89f67).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6007   +/-   ##
=======================================
  Coverage   97.50%   97.50%           
=======================================
  Files          80       80           
  Lines       14884    14884           
=======================================
  Hits        14513    14513           
  Misses        371      371           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MichaelChirico MichaelChirico merged commit 3a4ec47 into master Mar 18, 2024
5 checks passed
@MichaelChirico MichaelChirico deleted the test-fail-nonascii branch March 18, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants