-
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.
Add an option to put WinAppDriver output in a file (#151)
This enriches the internal `Win32ProcessTree` API to take `HANDLE` objects for stdin, stdout and stderr, as well as adding an option to use the parent console rather than spawning a new one.
- Loading branch information
Showing
3 changed files
with
158 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import TestsCommon | ||
import WinSDK | ||
import XCTest | ||
|
||
@testable import WebDriver | ||
@testable import WinAppDriver | ||
|
||
class AppDriverOptionsTest: XCTestCase { | ||
func tempFileName() -> String { | ||
return FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) | ||
.appendingPathExtension("txt").path | ||
} | ||
|
||
/// Tests that redirecting stdout to a file works. | ||
func testStdoutRedirectToFile() throws { | ||
let outputFile = try { | ||
// Start a new instance of msinfo32 and write the output to a file. | ||
let outputFile = tempFileName() | ||
let _ = try MSInfo32App( | ||
winAppDriver: WinAppDriver.start( | ||
outputFile: outputFile | ||
)) | ||
return outputFile | ||
}() | ||
|
||
// Read the output file. | ||
let output = try String(contentsOfFile: outputFile, encoding: .utf16LittleEndian) | ||
|
||
// Delete the file. | ||
try FileManager.default.removeItem(atPath: outputFile) | ||
|
||
XCTAssert(output.contains("msinfo32")) | ||
} | ||
} |