Skip to content

Commit

Permalink
Merge branch 'MobileNativeFoundation:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
memoto authored Dec 16, 2024
2 parents 49247af + 251e44b commit 897ac22
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ jobs:
SwiftLint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: SwiftLint
uses: norio-nomura/action-swiftlint@3.1.0
with:
args: --strict

macOS:
runs-on: macos-12
runs-on: macos-13
env:
XCODE_VERSION: ${{ '14.1' }}
steps:
- name: Select Xcode
run: "sudo xcode-select -s /Applications/Xcode_$XCODE_VERSION.app"
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: Build and Run
run: rake build[release]
- name: Test
Expand All @@ -32,7 +32,7 @@ jobs:
image: swift:5.7.1
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: Install Ruby
run: apt-get update && apt-get install -y ruby zlib1g-dev
- name: Build and Run
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
macOS:
name: Add macOS binaries to release
runs-on: macos-12
runs-on: macos-13
env:
XCODE_VERSION: ${{ '14.1' }}
steps:
Expand Down
16 changes: 15 additions & 1 deletion Sources/XCLogParser/activityparser/ActivityParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public class ActivityParser {
/// that into account
var isCommandLineLog = false

/// The version of the parsed `IDEActivityLog`.
/// Used to skip parsing of the `IDEActivityLogSectionAttachment` list on version less than 11.
var logVersion: Int8?

public init() {}

/// Parses the xcacticitylog argument into a `IDEActivityLog`
Expand All @@ -53,7 +57,9 @@ public class ActivityParser {

public func parseIDEActiviyLogFromTokens(_ tokens: [Token]) throws -> IDEActivityLog {
var iterator = tokens.makeIterator()
return IDEActivityLog(version: Int8(try parseAsInt(token: iterator.next())),
let logVersion = Int8(try parseAsInt(token: iterator.next()))
self.logVersion = logVersion
return IDEActivityLog(version: logVersion,
mainSection: try parseLogSection(iterator: &iterator))
}

Expand Down Expand Up @@ -458,6 +464,14 @@ public class ActivityParser {

private func parseIDEActivityLogSectionAttachments(iterator: inout IndexingIterator<[Token]>)
throws -> [IDEActivityLogSectionAttachment] {
guard let logVersion else {
throw XCLogParserError.parseError("Log version not parsed before parsing " +
"array of IDEActivityLogSectionAttachment")
}
/// The list of IDEActivityLogSectionAttachment was introduced with version 11
guard logVersion >= 11 else {
return []
}
guard let listToken = iterator.next() else {
throw XCLogParserError.parseError("Unexpected EOF parsing array of IDEActivityLogSectionAttachment")
}
Expand Down
60 changes: 60 additions & 0 deletions Tests/XCLogParserTests/ActivityParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,34 @@ class ActivityParserTests: XCTestCase {
return startTokens + logMessageTokens + endTokens
}()

lazy var IDEActivityLogSectionTokensWithoutAttachments: [Token] = {
let startTokens = [Token.int(2),
Token.string("com.apple.dt.IDE.BuildLogSection"),
Token.string("Prepare build"),
Token.string("Prepare build"),
Token.double(575479851.278759),
Token.double(575479851.778325),
Token.null,
Token.string("note: Using legacy build system"),
Token.list(1),
Token.className("IDEActivityLogMessage"),
Token.classNameRef("IDEActivityLogMessage"),
]
let logMessageTokens = IDEActivityLogMessageTokens
let endTokens = [Token.int(1),
Token.int(0),
Token.int(1),
Token.string("subtitle"),
Token.null,
Token.string("commandDetailDesc"),
Token.string("501796C4-6BE4-4F80-9F9D-3269617ECC17"),
Token.string("localizedResultString"),
Token.string("xcbuildSignature"),
Token.int(0)
]
return startTokens + logMessageTokens + endTokens
}()

let IDEConsoleItemTokens: [Token] = [
Token.className("IDEConsoleItem"),
Token.classNameRef("IDEConsoleItem"),
Expand Down Expand Up @@ -288,6 +316,7 @@ class ActivityParserTests: XCTestCase {
}

func testParseIDEActivityLogSection() throws {
parser.logVersion = 11
let tokens = IDEActivityLogSectionTokens
var iterator = tokens.makeIterator()
let logSection = try parser.parseIDEActivityLogSection(iterator: &iterator)
Expand All @@ -310,15 +339,46 @@ class ActivityParserTests: XCTestCase {
XCTAssertEqual("501796C4-6BE4-4F80-9F9D-3269617ECC17", logSection.uniqueIdentifier)
XCTAssertEqual("localizedResultString", logSection.localizedResultString)
XCTAssertEqual("xcbuildSignature", logSection.xcbuildSignature)
XCTAssertEqual(1, logSection.attachments.count)
XCTAssertEqual(0, logSection.unknown)
}

func testParseIDEActivityLogSection_version10() throws {
parser.logVersion = 10
let tokens = IDEActivityLogSectionTokensWithoutAttachments
var iterator = tokens.makeIterator()
let logSection = try parser.parseIDEActivityLogSection(iterator: &iterator)
XCTAssertEqual(2, logSection.sectionType)
XCTAssertEqual("com.apple.dt.IDE.BuildLogSection", logSection.domainType)
XCTAssertEqual("Prepare build", logSection.title)
XCTAssertEqual("Prepare build", logSection.signature)
XCTAssertEqual(575479851.278759, logSection.timeStartedRecording)
XCTAssertEqual(575479851.778325, logSection.timeStoppedRecording)
XCTAssertEqual(0, logSection.subSections.count)
XCTAssertEqual("note: Using legacy build system", logSection.text)
XCTAssertEqual(1, logSection.messages.count)
XCTAssertTrue(logSection.wasCancelled)
XCTAssertFalse(logSection.isQuiet)
XCTAssertTrue(logSection.wasFetchedFromCache)
XCTAssertEqual("subtitle", logSection.subtitle)
XCTAssertEqual("", logSection.location.documentURLString)
XCTAssertEqual(0, logSection.location.timestamp)
XCTAssertEqual("commandDetailDesc", logSection.commandDetailDesc)
XCTAssertEqual("501796C4-6BE4-4F80-9F9D-3269617ECC17", logSection.uniqueIdentifier)
XCTAssertEqual("localizedResultString", logSection.localizedResultString)
XCTAssertEqual("xcbuildSignature", logSection.xcbuildSignature)
XCTAssertEqual(0, logSection.attachments.count)
XCTAssertEqual(0, logSection.unknown)
}

func testParseActivityLog() throws {
let activityLog = try parser.parseIDEActiviyLogFromTokens(IDEActivityLogTokens)
XCTAssertEqual(10, activityLog.version)
XCTAssertEqual(10, parser.logVersion)
}

func testParseDBGConsoleLog() throws {
parser.logVersion = 11
let tokens = DBGConsoleLogTokens
var iterator = tokens.makeIterator()
let DBGConsoleLog = try parser.parseDBGConsoleLog(iterator: &iterator)
Expand Down

0 comments on commit 897ac22

Please sign in to comment.