From fcb20571158911188c0e651e84f4155e5969d448 Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Mon, 11 Sep 2023 18:02:19 +0530 Subject: [PATCH] fix(tests): put locale tests behind flag lock --- tests/datetime/formatTime.luau | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/tests/datetime/formatTime.luau b/tests/datetime/formatTime.luau index a3ae646..f232f86 100644 --- a/tests/datetime/formatTime.luau +++ b/tests/datetime/formatTime.luau @@ -8,12 +8,6 @@ assert( "invalid ISO 8601 formatting for DateTime.formatTime() (UTC)" ) -assert( - DateTime.fromUnixTimestamp(1693068988):formatTime("utc", "%A, %d %B %Y", "fr") - == "samedi, 26 août 2023", - "expected format specifier '%A, %d %B %Y' to return 'samedi, 26 août 2023' for locale 'fr' (UTC)" -) - local expectedTimeString = os.date("%Y-%m-%dT%H:%M:%SZ", 1694078954) assert( @@ -23,7 +17,7 @@ assert( ) -- This test requires 'fr_FR.UTF-8 UTF-8' to be in /etc/locale.gen to pass --- Locale should be set up by a script, or by the user, or in CI, test runner +-- Locale should be set up by a script, or by the user, or in CI, test runner -- takes no responsibility for this -- Local Timezone @@ -34,6 +28,21 @@ assert( "invalid ISO 8601 formatting for DateTime.formatTime() (local)" ) +-- To run tests related to locales, one must explicitly +-- provide the `--test-locales` flag +local toTestLocales = false + +for _, arg in process.args do + if arg == "--test-locales" then + toTestLocales = true + break + end +end + +if not toTestLocales then + return true +end + local expectedLocalizedString local dateCmd = process.spawn("bash", { "-c", "date +\"%A, %d %B %Y\" --date='@1693068988'" }, { @@ -53,3 +62,9 @@ assert( == expectedLocalizedString, `expected format specifier '%A, %d %B %Y' to return '{expectedLocalizedString}' for locale 'fr' (local)` ) + +assert( + DateTime.fromUnixTimestamp(1693068988):formatTime("utc", "%A, %d %B %Y", "fr") + == "samedi, 26 août 2023", + "expected format specifier '%A, %d %B %Y' to return 'samedi, 26 août 2023' for locale 'fr' (UTC)" +)