Files
L'électron rare 48d019cc77 fix(avlivebody): apply phase 2 review fixes
The phase 2 code review surfaced four follow-ups left after merge.
The joint accessor indexed body.valid without checking its length,
so a short valid array could crash on out-of-range access; it now
guards i < body.valid.count. The viz mode name list was rebuilt on
every modeName() call, so it is hoisted to a static constant. A
Metal shader compile test is added to catch scene.metal regressions
in CI. The dead SceneView placeholder, superseded by LayeredSceneView,
is removed.
2026-06-26 14:50:07 +02:00

23 lines
1023 B
Swift

// avlivebody-mac/Tests/AVLiveBodyTests/ShaderCompileTests.swift
import XCTest
import Metal
@testable import AVLiveBody
final class ShaderCompileTests: XCTestCase {
func testSceneMetalCompiles() throws {
let here = URL(fileURLWithPath: #filePath) // .../Tests/AVLiveBodyTests/ShaderCompileTests.swift
let shader = here
.deletingLastPathComponent() // AVLiveBodyTests
.deletingLastPathComponent() // Tests
.deletingLastPathComponent() // avlivebody-mac
.appendingPathComponent("Sources/AVLiveBody/Resources/scene.metal")
let src = try String(contentsOf: shader, encoding: .utf8)
guard let dev = MTLCreateSystemDefaultDevice() else {
throw XCTSkip("no Metal device")
}
let lib = try dev.makeLibrary(source: src, options: MTLCompileOptions())
XCTAssertNotNil(lib.makeFunction(name: "bg_vertex"))
XCTAssertNotNil(lib.makeFunction(name: "bg_fragment"))
}
}