Skip to content

Commit

Permalink
Fix Node.js test harness to output stdout/stderr (#485)
Browse files Browse the repository at this point in the history
* Fix Node.js test harness to output stdout/stderr

Follow-up to 3cb3877

Also added test assertion to ensure the XCTest output
is printed to stderr

* Fix test for Swift 5.10
  • Loading branch information
kateinoigakukun committed Jun 13, 2024
1 parent 193722e commit 1b7daf2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/CartonKit/Server/StaticArchive.swift

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Tests/CartonCommandTests/TestCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ final class TestCommandTests: XCTestCase {
["carton", "test", "--environment", "node"], packageDirectory: packageDirectory.asURL
)
try result.checkNonZeroExit()
let stdout = try result.utf8Output()
let stderr = try result.utf8stderrOutput()
let expectedContent = "Test Suite 'All tests' passed"
// SwiftPM changed the output destination of SwiftPM Plugin in 6.0
XCTAssertTrue(stdout.contains(expectedContent) || stderr.contains(expectedContent))
}
}

Expand Down
10 changes: 9 additions & 1 deletion entrypoint/testNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ const startWasiTask = async () => {
// No JavaScriptKit module found, run the Wasm module without JSKit
}

const wasmRunner = WasmRunner({ args: testArgs }, runtimeConstructor);
const wasmRunner = WasmRunner({
args: testArgs,
onStdoutLine: (line) => {
console.log(line);
},
onStderrLine: (line) => {
console.error(line);
},
}, runtimeConstructor);
let procExitCalled = false;

process.on("beforeExit", () => {
Expand Down

0 comments on commit 1b7daf2

Please sign in to comment.