fix os2.process_exec on non-windows and add a smoke test

This commit is contained in:
Laytan Laats
2024-10-03 13:51:27 +02:00
parent 0d834a2c2e
commit 76806080ef
4 changed files with 78 additions and 35 deletions
+1
View File
@@ -33,6 +33,7 @@ download_assets :: proc() {
@(require) import "net"
@(require) import "odin"
@(require) import "os"
@(require) import "os/os2"
@(require) import "path/filepath"
@(require) import "reflect"
@(require) import "runtime"
+28
View File
@@ -0,0 +1,28 @@
package tests_core_os_os2
import "base:runtime"
import "core:log"
import os "core:os/os2"
import "core:testing"
_ :: log
@(test)
test_process_exec :: proc(t: ^testing.T) {
state, stdout, stderr, err := os.process_exec({
command = {"echo", "hellope"},
}, context.allocator)
defer delete(stdout)
defer delete(stderr)
when (ODIN_OS not_in runtime.Odin_OS_Types{.Linux, .Darwin, .Windows}) {
testing.expect_value(t, err, os.General_Error.Unsupported)
_ = state
} else {
testing.expect_value(t, state.exited, true)
testing.expect_value(t, state.success, true)
testing.expect_value(t, err, nil)
testing.expect_value(t, string(stdout), "hellope\n")
}
}