@@ -986,19 +986,28 @@ end
986986@test_nowarn Core. eval (Main, :(import .... Main))
987987
988988# issue #27239
989+ using Base. BinaryPlatforms: HostPlatform, libc
989990@testset " strftime tests issue #27239" begin
990- # change to non-Unicode Korean
991+ # change to non-Unicode Korean to test that it is properly transcoded into valid UTF-8
991992 korloc = [" ko_KR.EUC-KR" , " ko_KR.CP949" , " ko_KR.949" , " Korean_Korea.949" ]
992- timestrs = String[]
993- withlocales (korloc) do
994- # system dependent formats
995- push! (timestrs, Libc. strftime (0.0 ))
996- push! (timestrs, Libc. strftime (" %a %A %b %B %p %Z" , 0 ))
993+ at_least_one_locale_found = false
994+ withlocales (korloc) do locale
995+ at_least_one_locale_found = true
996+ # Test both the default format and a custom formatting string
997+ for s in (Libc. strftime (0.0 ), Libc. strftime (" %a %A %b %B %p %Z" , 0 ))
998+ # Ensure that we always get valid UTF-8 back
999+ @test isvalid (s)
1000+
1001+ # On `musl` it is impossible for `setlocale` to fail, it just falls back to
1002+ # the default system locale, which on our buildbots is en_US.UTF-8. We'll
1003+ # assert that what we get does _not_ start with `Thu`, as that's what all
1004+ # en_US.UTF-8 encodings would start with.
1005+ # X-ref: https://musl.openwall.narkive.com/kO1vpTWJ/setlocale-behavior-with-missing-locales
1006+ @test ! startswith (s, " Thu" ) broken= (libc (HostPlatform ()) == " musl" )
1007+ end
9971008 end
998- # tests
999- isempty (timestrs) && @warn " skipping stftime tests: no locale found for testing"
1000- for s in timestrs
1001- @test isvalid (s)
1009+ if ! at_least_one_locale_found
1010+ @warn " skipping stftime tests: no locale found for testing"
10021011 end
10031012end
10041013
0 commit comments