-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get AbstractFileSystemTest running on WASM (#1316)
* Get AbstractFileSystemTest running on WASM * Get many tests from AbstractFileSystemTest passing Still some follow-ups to do. * Fixup workingDirectory delegation * Update okio-testing-support/src/nonWasmMain/kotlin/okio/TestingNonWasm.kt Co-authored-by: Benoît Quenaudon <bquenaudon@squareup.com> --------- Co-authored-by: Benoît Quenaudon <bquenaudon@squareup.com>
- Loading branch information
1 parent
0709c1f
commit 0aac566
Showing
14 changed files
with
330 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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 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 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
55 changes: 55 additions & 0 deletions
55
okio-testing-support/src/nonWasmMain/kotlin/okio/TestingNonWasm.kt
This file contains 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,55 @@ | ||
/* | ||
* Copyright (C) 2023 Square, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package okio | ||
|
||
import okio.fakefilesystem.FakeFileSystem | ||
|
||
actual typealias Clock = kotlinx.datetime.Clock | ||
|
||
actual typealias Instant = kotlinx.datetime.Instant | ||
|
||
actual fun fromEpochSeconds( | ||
epochSeconds: Long, | ||
) = Instant.fromEpochSeconds(epochSeconds) | ||
|
||
actual fun fromEpochMilliseconds( | ||
epochMilliseconds: Long, | ||
) = Instant.fromEpochMilliseconds(epochMilliseconds) | ||
|
||
actual val FileSystem.isFakeFileSystem: Boolean | ||
get() = this is FakeFileSystem | ||
|
||
actual val FileSystem.allowSymlinks: Boolean | ||
get() = (this as? FakeFileSystem)?.allowSymlinks == true | ||
|
||
actual val FileSystem.allowReadsWhileWriting: Boolean | ||
get() = (this as? FakeFileSystem)?.allowReadsWhileWriting == true | ||
|
||
actual var FileSystem.workingDirectory: Path | ||
get() { | ||
return when (this) { | ||
is FakeFileSystem -> workingDirectory | ||
is ForwardingFileSystem -> delegate.workingDirectory | ||
else -> error("cannot get working directory: $this") | ||
} | ||
} | ||
set(value) { | ||
when (this) { | ||
is FakeFileSystem -> workingDirectory = value | ||
is ForwardingFileSystem -> delegate.workingDirectory = value | ||
else -> error("cannot set working directory: $this") | ||
} | ||
} |
Oops, something went wrong.