Skip to content

Commit 27648e7

Browse files
committed
Remove the default output buffer limit
1 parent 4879837 commit 27648e7

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

Sources/Subprocess/IO/Output.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public protocol OutputProtocol: Sendable, ~Copyable {
4646
#endif
4747
extension OutputProtocol {
4848
/// The max amount of data to collect for this output.
49-
public var maxSize: Int { 128 * 1024 }
49+
public var maxSize: Int { .max }
5050
}
5151

5252
/// A concrete `Output` type for subprocesses that indicates that
@@ -240,10 +240,9 @@ extension OutputProtocol where Self == FileDescriptorOutput {
240240
@available(SubprocessSpan, *)
241241
#endif
242242
extension OutputProtocol where Self == StringOutput<UTF8> {
243-
/// Create a `Subprocess` output that collects output as
244-
/// UTF8 String with 128kb limit.
243+
/// Create a `Subprocess` output that collects output as UTF8 String
245244
public static var string: Self {
246-
.init(limit: 128 * 1024, encoding: UTF8.self)
245+
.init(limit: .max, encoding: UTF8.self)
247246
}
248247
}
249248

@@ -265,9 +264,8 @@ extension OutputProtocol {
265264
@available(SubprocessSpan, *)
266265
#endif
267266
extension OutputProtocol where Self == BytesOutput {
268-
/// Create a `Subprocess` output that collects output as
269-
/// `Buffer` with 128kb limit.
270-
public static var bytes: Self { .init(limit: 128 * 1024) }
267+
/// Create a `Subprocess` output that collects output as `Buffer`
268+
public static var bytes: Self { .init(limit: .max) }
271269

272270
/// Create a `Subprocess` output that collects output as
273271
/// `Buffer` up to limit it bytes.

Tests/SubprocessTests/SubprocessTests+Unix.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,25 @@ extension SubprocessUnixTests {
955955
}
956956
#expect(result == .unhandledException(SIGKILL))
957957
}
958+
959+
@Test func testUnlimitedBufferByDefault() async throws {
960+
guard #available(SubprocessSpan , *) else {
961+
return
962+
}
963+
964+
// Make sure we can read long text from standard input
965+
let expected: Data = try Data(
966+
contentsOf: URL(filePath: theMysteriousIsland.string)
967+
)
968+
// Launch cat with default output `.string`
969+
let cat = try await Subprocess.run(
970+
.path("/bin/cat"),
971+
arguments: ["\(theMysteriousIsland.string)"]
972+
)
973+
#expect(cat.terminationStatus.isSuccess)
974+
// Make sure we read all bytes
975+
#expect(cat.standardOutput!.data(using: .utf8) == expected)
976+
}
958977
}
959978

960979
// MARK: - Utils

0 commit comments

Comments
 (0)