chore: import upstream snapshot with attribution
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
fn testing_helpers_ok() -> Bool {
|
||||
let bytes: Span<u8> = "zerolang"
|
||||
if !std.testing.isTrue(true) {
|
||||
return false
|
||||
}
|
||||
if !std.testing.isFalse(false) {
|
||||
return false
|
||||
}
|
||||
if !std.testing.equalBool(true, true) {
|
||||
return false
|
||||
}
|
||||
if !std.testing.equalUsize(std.mem.len(bytes), 8) {
|
||||
return false
|
||||
}
|
||||
if !std.testing.equalU32(42_u32, 42_u32) {
|
||||
return false
|
||||
}
|
||||
if !std.testing.equalI32(-7, -7) {
|
||||
return false
|
||||
}
|
||||
if !std.testing.equalBytes("zero", "zero") {
|
||||
return false
|
||||
}
|
||||
if !std.testing.containsBytes(bytes, "lang") {
|
||||
return false
|
||||
}
|
||||
if !std.testing.startsWith(bytes, "zero") {
|
||||
return false
|
||||
}
|
||||
if !std.testing.endsWith(bytes, "lang") {
|
||||
return false
|
||||
}
|
||||
if !std.testing.notEqualBytes("zero", "lang") {
|
||||
return false
|
||||
}
|
||||
let diff: Maybe<usize> = std.testing.diffIndexBytes("zero", "zeta")
|
||||
if !diff.has || diff.value != 2 {
|
||||
return false
|
||||
}
|
||||
let same: Maybe<usize> = std.testing.diffIndexBytes("zero", "zero")
|
||||
if same.has {
|
||||
return false
|
||||
}
|
||||
if !std.testing.jsonFieldEquals("{\"ok\":true,\"count\":2}", "count", "2") {
|
||||
return false
|
||||
}
|
||||
if !std.testing.jsonPathEquals("{\"user\":{\"name\":\"zero\"}}", "user.name", "\"zero\"") {
|
||||
return false
|
||||
}
|
||||
var case_storage: [32]u8 = [0_u8; 32]
|
||||
let case_name: Maybe<Span<u8>> = std.testing.caseName(case_storage, "json", 3)
|
||||
if !case_name.has || !std.testing.equalBytes(case_name.value, "json[3]") {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fn log_message_ok() -> Bool {
|
||||
var storage: [128]u8 = [0_u8; 128]
|
||||
let entry: Maybe<Span<u8>> = std.log.message(storage, "info", "agent ready")
|
||||
if entry.has {
|
||||
if !std.testing.startsWith(entry.value, "{\"level\":\"info\"") {
|
||||
return false
|
||||
}
|
||||
if !std.testing.containsBytes(entry.value, "\"message\":\"agent ready\"") {
|
||||
return false
|
||||
}
|
||||
return std.testing.endsWith(entry.value, "}\n")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fn log_key_value_ok() -> Bool {
|
||||
var storage: [128]u8 = [0_u8; 128]
|
||||
let entry: Maybe<Span<u8>> = std.log.keyValue(storage, "info", "event", "startup")
|
||||
if entry.has {
|
||||
if !std.testing.startsWith(entry.value, "{\"level\":\"info\"") {
|
||||
return false
|
||||
}
|
||||
if !std.testing.containsBytes(entry.value, "\"key\":\"event\"") {
|
||||
return false
|
||||
}
|
||||
return std.testing.containsBytes(entry.value, "\"value\":\"startup\"")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fn log_message_field_ok() -> Bool {
|
||||
var storage: [160]u8 = [0_u8; 160]
|
||||
var field_storage: [64]u8 = [0_u8; 64]
|
||||
let field: Maybe<Span<u8>> = std.log.stringField(field_storage, "route", "/health")
|
||||
if field.has {
|
||||
let entry: Maybe<Span<u8>> = std.log.messageField(storage, std.log.levelInfo(), "request handled", field.value)
|
||||
if !entry.has {
|
||||
return false
|
||||
}
|
||||
if !std.testing.startsWith(entry.value, "{\"level\":\"info\"") {
|
||||
return false
|
||||
}
|
||||
if !std.testing.containsBytes(entry.value, "\"message\":\"request handled\"") {
|
||||
return false
|
||||
}
|
||||
return std.testing.containsBytes(entry.value, "\"route\":\"/health\"")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fn log_redacted_ok() -> Bool {
|
||||
var storage: [128]u8 = [0_u8; 128]
|
||||
let entry: Maybe<Span<u8>> = std.log.redacted(storage, std.log.levelWarn(), "authorization")
|
||||
if entry.has {
|
||||
if !std.testing.containsBytes(entry.value, "\"key\":\"authorization\"") {
|
||||
return false
|
||||
}
|
||||
return std.testing.containsBytes(entry.value, "\"redacted\":true")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fn log_level_names_ok() -> Bool {
|
||||
var debug_storage: [96]u8 = [0_u8; 96]
|
||||
var error_storage: [96]u8 = [0_u8; 96]
|
||||
let debug_entry: Maybe<Span<u8>> = std.log.message(debug_storage, std.log.levelDebug(), "debug path")
|
||||
let error_entry: Maybe<Span<u8>> = std.log.message(error_storage, std.log.levelError(), "error path")
|
||||
if !debug_entry.has || !error_entry.has {
|
||||
return false
|
||||
}
|
||||
return std.testing.containsBytes(debug_entry.value, "\"level\":\"debug\"") && std.testing.containsBytes(error_entry.value, "\"level\":\"error\"")
|
||||
}
|
||||
|
||||
pub fn main(world: World) -> Void raises {
|
||||
if testing_helpers_ok() && log_message_ok() && (log_key_value_ok() && log_message_field_ok()) && (log_redacted_ok() && log_level_names_ok()) {
|
||||
check world.out.write("std testing log ok\n")
|
||||
} else {
|
||||
check world.out.write("std testing log failed\n")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user