-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first draft * unwritable file tests * add swift 5.7 tests * update pattern match for cross platform * update swift install action * fix tests * linux error Co-authored-by: Full Queue Developer <[email protected]>
- Loading branch information
1 parent
2a434c7
commit fc6bfa4
Showing
4 changed files
with
91 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import XCTest | ||
@testable import Sh | ||
|
||
final class LogFileTests: XCTestCase { | ||
|
||
func testSimple() throws { | ||
|
||
do { | ||
try sh(.file("/tmp/sh-test.log"), #"echo "simple" > /unknown/path/name"#) | ||
XCTFail("Expected the above to throw an `Errors.errorWithLogInfo`") | ||
} catch Errors.errorWithLogInfo(let logInfo, underlyingError: let underlyingError) { | ||
|
||
XCTAssertTrue(logInfo.contains("/unknown/path/name")) | ||
|
||
let terminationError = try XCTUnwrap(underlyingError as? TerminationError) | ||
|
||
XCTAssertNotEqual(terminationError.status, 0) | ||
XCTAssertEqual(terminationError.reason, "`regular exit`") | ||
} catch { | ||
XCTFail("Expected the above to throw an `Errors.errorWithLogInfo`, instead got an \(error)") | ||
} | ||
} | ||
|
||
func testUnwritableLogfile() throws { | ||
do { | ||
try sh(.file("/missing/path/sh-test.log"), #"echo "simple" > /unknown/path/name"#) | ||
} catch Errors.openingLogError(let logError, underlyingError: let underlyingError) { | ||
|
||
#if os(Linux) | ||
XCTAssertEqual(logError.localizedDescription, "The operation could not be completed. No such file or directory") | ||
#else | ||
XCTAssertEqual(logError.localizedDescription, "The file “sh-test.log” couldn’t be opened because there is no such file.") | ||
#endif | ||
|
||
XCTAssertTrue(underlyingError.localizedDescription.contains("CouldNotCreateFile error")) | ||
|
||
} catch { | ||
XCTFail("Expected an opening log error, but got \(error)") | ||
} | ||
} | ||
} |