This repository has been archived by the owner on Jan 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write stdout/stderr directly, replace Xcode reporter
- Loading branch information
Showing
11 changed files
with
210 additions
and
108 deletions.
There are no files selected for viewing
Submodule FBSimulatorControl
updated
44 files
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,75 @@ | ||
// | ||
// FileReader.swift | ||
// pxctest | ||
// | ||
// Created by Johannes Plunien on 20/02/2017. | ||
// Copyright © 2017 Johannes Plunien. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
final class FileReader { | ||
|
||
private var buffer: Data | ||
private let chunkSize: Int | ||
private let encoding: String.Encoding | ||
private var eof: Bool | ||
private var fileHandle: FileHandle? | ||
private let delimiter: Data | ||
|
||
init?(path: String, delimiter: String = "\n", encoding: String.Encoding = .utf8, chunkSize: Int = 4096) { | ||
guard | ||
let fileHandle = FileHandle(forReadingAtPath: path), | ||
let delimiter = delimiter.data(using: encoding) | ||
else { return nil } | ||
|
||
self.buffer = Data(capacity: chunkSize) | ||
self.chunkSize = chunkSize | ||
self.delimiter = delimiter | ||
self.encoding = encoding | ||
self.eof = false | ||
self.fileHandle = fileHandle | ||
} | ||
|
||
deinit { | ||
fileHandle?.closeFile() | ||
fileHandle = nil | ||
} | ||
|
||
func nextLine() -> String? { | ||
guard let fileHandle = fileHandle else { | ||
return nil | ||
} | ||
|
||
while !eof { | ||
if let range = buffer.range(of: delimiter) { | ||
let line = String(data: buffer.subdata(in: 0..<range.upperBound), encoding: encoding) | ||
buffer.removeSubrange(0..<range.upperBound) | ||
return line | ||
} | ||
let tmpData = fileHandle.readData(ofLength: chunkSize) | ||
if tmpData.count > 0 { | ||
buffer.append(tmpData) | ||
} else { | ||
eof = true | ||
if buffer.count > 0 { | ||
let line = String(data: buffer as Data, encoding: encoding) | ||
buffer.count = 0 | ||
return line | ||
} | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
} | ||
|
||
extension FileReader: Sequence { | ||
|
||
func makeIterator() -> AnyIterator<String> { | ||
return AnyIterator { | ||
return self.nextLine() | ||
} | ||
} | ||
|
||
} |
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,35 @@ | ||
// | ||
// FileWriter.swift | ||
// pxctest | ||
// | ||
// Created by Johannes Plunien on 20/02/2017. | ||
// Copyright © 2017 Johannes Plunien. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
final class FileWriter { | ||
|
||
private let encoding: String.Encoding | ||
private var fileHandle: FileHandle? | ||
|
||
init?(path: String, encoding: String.Encoding = .utf8) { | ||
FileManager.default.createFile(atPath: path, contents: nil, attributes: nil) | ||
|
||
guard let fileHandle = FileHandle(forWritingAtPath: path) else { return nil } | ||
|
||
self.encoding = encoding | ||
self.fileHandle = fileHandle | ||
} | ||
|
||
deinit { | ||
fileHandle?.closeFile() | ||
fileHandle = nil | ||
} | ||
|
||
func write(string: String) { | ||
guard let data = string.data(using: encoding) else { return } | ||
fileHandle?.write(data) | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
// | ||
// FileReaderTests.swift | ||
// pxctest | ||
// | ||
// Created by Johannes Plunien on 20/02/2017. | ||
// Copyright © 2017 Johannes Plunien. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import PXCTestKit | ||
|
||
class FileReaderTests: XCTestCase { | ||
|
||
func testNextLine() { | ||
var expectedLines = Array([ | ||
"this\n", | ||
"is\n", | ||
"some\n", | ||
"text\n", | ||
"lastline\n", | ||
].reversed()) | ||
let reader = FileReader(path: fixtures.textFilePath)! | ||
for line in reader { | ||
XCTAssertEqual(line, expectedLines.popLast()) | ||
} | ||
} | ||
|
||
} |
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,5 @@ | ||
this | ||
is | ||
some | ||
text | ||
lastline |
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
Oops, something went wrong.
dc69f3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plu Thanks for these changes. Just a few questions. I have tried running with these changes and there is now no delay after testings but I don't know where the log files are written to. I have specified '--output /Users/dave/Desktop/Logs' but I no longer get any files generated under 'iPhone 6s' directory. I only get the junit file in Users/dave/Desktop/Logs and the directory structure down to 'iPhone 6s' directory but it contains no files.
Also, is it possible to generate a junit xml file per device like previously?
dc69f3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately I did not add an option for this, so the new behaviour is kind of set in stone (or code). But pull requests are welcome. The new
junit.xml
contains namespaces, so Jenkins will pick that up and show it nicely per target and device.There should be something in
/Users/dave/Desktop/Logs
per device and per test target. Inside you should find a log file named like your Application.What kind of tests are you running there, just XCTest or some XCUITest ones?
dc69f3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's ok, we will be using Jenkins anyway.
I get this: /Users/dave/Desktop/Logs/UITests/iOS 10.2/iPhone 6s
but previous to these changes it contained app.log and test.log but now it is empty after testing.
I'm running a XCUITest scheme.
dc69f3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, that's strange. Now it should contain only one log file (
app.log
) which should have exactly the same content as you'd see in the Xcode console. I'll try to reproduce the problem.dc69f3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created a ticket and try to look at it tomorrow: #23
dc69f3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, great. Thanks
dc69f3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, one more question: Can you please show me the output of
pxctest version
? So I can see on which commit you were, will make reproducing the issue easier, hopefully. Thanks!dc69f3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pxctest 0.3.1 (dc69f3b)
Appreciate the help with this.