-
Notifications
You must be signed in to change notification settings - Fork 115
Support obtaining the system timezone on old Debian-based distributions #503
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
Merged
Merged
Changes from all commits
Commits
Show all changes
82 commits
Select commit
Hold shift + click to select a range
ed6e3cd
#430: Add testcontainers dependencies
DmitryNekrasov 37e67fe
#430: Add dockerfiles
DmitryNekrasov 0e4aadd
#430: Fix build.gradle.kts to depend on JUnit 5 to correct running of…
DmitryNekrasov 20dc7bc
#430: Add container initialization, run simple commant inside contain…
DmitryNekrasov fbbd55f
#430: Add logger configuration
DmitryNekrasov 5facbfa
#430: dockerfilePath refactoring
DmitryNekrasov 8cfd36d
#430: Run tests inside containers
DmitryNekrasov 683ce09
#430: Add defaultTimeZoneTest that runs inside containers
DmitryNekrasov e638490
#430: Split test on 2, pass cantainer as parameter
DmitryNekrasov 3d59b39
#430: Add BeforeAll buildTestBinary
DmitryNekrasov 0614e61
#430: Fix container stdout
DmitryNekrasov d294ac1
#430: Move defaultTimeZoneTest from common to linux/native
DmitryNekrasov fc08cb9
#430: Check INSIDE_TESTCONTAINERS env var to run test only in testcon…
DmitryNekrasov 403ebf9
#430: Replace shouldRunTests check to Testcontainers.runIfAvailable
DmitryNekrasov 54ad227
#430: Refactor Skipping test message
DmitryNekrasov 1d0ff83
#430: Rename TimeZoneTest to TimeZoneConfigurationTest
DmitryNekrasov 62e4f5b
#430: Split runTest to runTimeZoneTests and runAllTests
DmitryNekrasov 6d84895
#430: Test fail is execResult.exitCode != 0
DmitryNekrasov 7d620bd
#430: Removed unnecessary dependency junit-params
DmitryNekrasov 269db7f
#430: First working iteration
DmitryNekrasov acfc235
#430: Add file comparison + some refactoring
DmitryNekrasov c52b60a
#430: Minor refactoring
DmitryNekrasov e36db1b
#430: Add 3 tests
DmitryNekrasov ddb105d
#430: Refactoring
DmitryNekrasov 733158d
#430: Add allTimeZoneFilesMissingTest test, fails because of Expected…
DmitryNekrasov a156cad
#430: Add symlinkTimeZoneTest
DmitryNekrasov efc67b8
#430: Add invalidTimezoneFormatTest
DmitryNekrasov 5902399
#430: Add commonTimeZoneTests
DmitryNekrasov 325f92b
#430: Change Z to UTC in currentSystemDefaultZone()
DmitryNekrasov 03e03c7
#430: UTC -> Z
DmitryNekrasov 9f8aac8
#430: Add 2 new Dockerfile for Debian Jessie and Ubuntu 24.04
DmitryNekrasov 0697ae8
#430: Fix platform for ubuntu
DmitryNekrasov dfdcb2a
#430: Remove some tests, run 2 tests on Debian Jessie
DmitryNekrasov bff21b1
#430: Add INSIDE_TESTCONTAINERS env var to Dockerfiles
DmitryNekrasov 6b15d79
#430: Fix defaultTimeZoneTest test
DmitryNekrasov 0ee491f
#430: Run tests on both containers
DmitryNekrasov 548ed68
#430: Refactoring
DmitryNekrasov c9cf312
#430: Refactor tests
DmitryNekrasov 0e7a3c9
#430: Refactor tests
DmitryNekrasov 0240f49
#430: Add jessieDefaultConfigTest, jessieMissingLocaltimeTest, nobleD…
DmitryNekrasov c007bac
#430: Move ContainerType
DmitryNekrasov 95dd6d9
#430: Refactor dockerfiles
DmitryNekrasov 38cab93
#430: Refactor ContainerType
DmitryNekrasov 9ee58d7
#430: Add nobleIncorrectSymlinkTest
DmitryNekrasov 192f1a2
#430: Add disabledWithoutDocker = true (may help to users that don't …
DmitryNekrasov 1dc04aa
#430: Add @TestInstance(PER_CLASS) to TimeZoneConfigurationTest
DmitryNekrasov df35ba0
#430: Add jessieMissingTimezoneTest
DmitryNekrasov 2234375
#430: Add jessieIncorrectTimezoneTest
DmitryNekrasov 7a38874
#430: Add jessieDifferentTimezonesTest
DmitryNekrasov 7cc417f
#430: Add comment to fallsBackToUniversal
DmitryNekrasov d678adf
#430: Add container descriptions in ContainerType
DmitryNekrasov 7f48fc3
#430: Remove WORKDIR from dockerfiles
DmitryNekrasov d6aa923
#430: Remove logging duplication
DmitryNekrasov d7acaca
#430: Add comment to currentSystemDefaultZone
DmitryNekrasov 27d7306
#430: Add internal root field
DmitryNekrasov 816f2af
#430: Add correctSymlinkTest
DmitryNekrasov 901cc68
#430: Add TimeZoneConfigurationTest Ignore
DmitryNekrasov 2964b49
#430: Add fallsBackToUTC test
DmitryNekrasov 916703b
#430: Add pwd
DmitryNekrasov 12f56d9
#430: Remove 'core' from path
DmitryNekrasov bf689b3
#430: Add missingTimezoneTest
DmitryNekrasov ed277ba
#430: Add incorrectTimezoneTest
DmitryNekrasov 6cb1b0c
#430: Remove Oslo file from missing-localtime test
DmitryNekrasov e261749
#430: Add differentTimezonesTest
DmitryNekrasov b4f5cb3
#430: Add differentTimezonesTest
DmitryNekrasov da58775
#430: Remove pwd
DmitryNekrasov 1180d03
#430: Add test related files
DmitryNekrasov 159c4f2
#430: Remove testcontainers relaited files
DmitryNekrasov 33e3c7f
#430: Remove testcontainers dependencies
DmitryNekrasov 49480b8
#430: Remove logback-test.xml
DmitryNekrasov 27128e8
#430: Introduce withFakeRoot helper method
DmitryNekrasov 2198821
#430: Add comment about workaround
DmitryNekrasov 7105210
#430: Rename root to systemTimezoneSearchRoot
DmitryNekrasov 3866fbf
#430: Rename fallbackToUTCWhenNoLocaltime test
DmitryNekrasov f64b3bd
#430: Rename missingTimezoneWhenLocaltimeIsNotSymlinkTest test
DmitryNekrasov d2a9dca
#430: Remove exception message checks
DmitryNekrasov d429aa8
#430: Rename timezoneFileAgreesWithLocaltimeContents
DmitryNekrasov c446aa9
#430: Rename nonExistentTimezoneInTimezoneFile
DmitryNekrasov ea2b11f
#430: Rename timezoneFileDisagreesWithLocaltimeContentsTest
DmitryNekrasov 756c89e
#430: Refactoring
DmitryNekrasov dd3ce5d
#430: Change exception message check
DmitryNekrasov c68adb0
#430: Change exception message check
DmitryNekrasov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright 2019-2025 JetBrains s.r.o. and contributors. | ||
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. | ||
*/ | ||
|
||
package kotlinx.datetime.test | ||
|
||
import kotlinx.datetime.IllegalTimeZoneException | ||
import kotlinx.datetime.TimeZone | ||
import kotlinx.datetime.internal.systemTimezoneSearchRoot | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertFailsWith | ||
import kotlin.test.assertTrue | ||
|
||
class TimeZoneNativeTest { | ||
|
||
@Test | ||
fun correctSymlinkTest() = withFakeRoot("${RESOURCES}correct-symlink/") { | ||
val tz = TimeZone.currentSystemDefault() | ||
assertEquals(TimeZone.of("Europe/Oslo"), tz) | ||
} | ||
|
||
@Test | ||
fun timezoneFileAgreesWithLocaltimeContentsTest() = withFakeRoot("${RESOURCES}timezone-file-agrees-with-localtime-contents/") { | ||
val tz = TimeZone.currentSystemDefault() | ||
assertEquals(TimeZone.of("Europe/Oslo"), tz) | ||
} | ||
|
||
@Test | ||
fun fallbackToUTCWhenNoLocaltimeTest() = withFakeRoot("${RESOURCES}fallback-to-utc-when-no-localtime/") { | ||
val tz = TimeZone.currentSystemDefault() | ||
assertEquals(TimeZone.UTC, tz) | ||
} | ||
|
||
@Test | ||
fun missingTimezoneWhenLocaltimeIsNotSymlinkTest() = withFakeRoot("${RESOURCES}missing-timezone-when-localtime-is-not-symlink/") { | ||
assertFailsWith<IllegalTimeZoneException> { | ||
TimeZone.currentSystemDefault() | ||
} | ||
} | ||
|
||
@Test | ||
fun nonExistentTimezoneInTimezoneFileTest() = withFakeRoot("${RESOURCES}non-existent-timezone-in-timezone-file/") { | ||
assertFailsWith<IllegalTimeZoneException> { | ||
TimeZone.currentSystemDefault() | ||
} | ||
} | ||
|
||
@Test | ||
fun timezoneFileDisagreesWithLocaltimeContentsTest() = withFakeRoot("${RESOURCES}timezone-file-disagrees-with-localtime-contents/") { | ||
val exception = assertFailsWith<IllegalTimeZoneException> { | ||
TimeZone.currentSystemDefault() | ||
} | ||
|
||
assertTrue( | ||
exception.message?.contains("Europe/Oslo") == true, | ||
"Exception message does not contain 'Europe/Oslo' as expected" | ||
) | ||
DmitryNekrasov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
companion object { | ||
const val RESOURCES = "./linux/test/time-zone-native-test-resources/" | ||
|
||
private fun withFakeRoot(fakeRoot: String, action: () -> Unit) { | ||
val defaultRoot = systemTimezoneSearchRoot | ||
systemTimezoneSearchRoot = fakeRoot | ||
try { | ||
action() | ||
} finally { | ||
systemTimezoneSearchRoot = defaultRoot | ||
} | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
core/linux/test/time-zone-native-test-resources/correct-symlink/etc/localtime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../usr/share/zoneinfo/Europe/Oslo |
Binary file added
BIN
+2.18 KB
...linux/test/time-zone-native-test-resources/correct-symlink/usr/share/zoneinfo/Europe/Oslo
Binary file not shown.
Empty file.
Empty file.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions
1
.../test/time-zone-native-test-resources/non-existent-timezone-in-timezone-file/etc/timezone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
incorrect/timezone |
Binary file added
BIN
+2.18 KB
...ime-zone-native-test-resources/timezone-file-agrees-with-localtime-contents/etc/localtime
Binary file not shown.
1 change: 1 addition & 0 deletions
1
...time-zone-native-test-resources/timezone-file-agrees-with-localtime-contents/etc/timezone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Europe/Oslo |
Binary file added
BIN
+2.18 KB
...est-resources/timezone-file-agrees-with-localtime-contents/usr/share/zoneinfo/Europe/Oslo
Binary file not shown.
Binary file added
BIN
+2.24 KB
...-zone-native-test-resources/timezone-file-disagrees-with-localtime-contents/etc/localtime
Binary file not shown.
1 change: 1 addition & 0 deletions
1
...e-zone-native-test-resources/timezone-file-disagrees-with-localtime-contents/etc/timezone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Europe/Oslo |
Binary file added
BIN
+2.24 KB
...esources/timezone-file-disagrees-with-localtime-contents/usr/share/zoneinfo/Europe/Berlin
Binary file not shown.
Binary file added
BIN
+2.18 KB
...-resources/timezone-file-disagrees-with-localtime-contents/usr/share/zoneinfo/Europe/Oslo
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.