From c7c0c7e2ae0174972b6570619638301e437502bb Mon Sep 17 00:00:00 2001 From: yutailang0119 Date: Sat, 25 Aug 2018 10:05:00 +0900 Subject: [PATCH 01/11] Update swift-tools-version to 4.2 --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index e0e4c42..37fd73f 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:4.0 +// swift-tools-version:4.2 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription From 700fe45ebfbb20a2d48d1907ace8dae8c35a4654 Mon Sep 17 00:00:00 2001 From: yutailang0119 Date: Sat, 25 Aug 2018 10:10:00 +0900 Subject: [PATCH 02/11] Fix to use new features of Swift 4.2 --- Sources/ProgressSpinnerKit/Spinner.swift | 2 +- .../ProgressSpinnerTests.swift | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Sources/ProgressSpinnerKit/Spinner.swift b/Sources/ProgressSpinnerKit/Spinner.swift index 4fbae63..137065a 100644 --- a/Sources/ProgressSpinnerKit/Spinner.swift +++ b/Sources/ProgressSpinnerKit/Spinner.swift @@ -27,7 +27,7 @@ public struct Spinner { cursor = 0 } - public enum Kind { + public enum Kind: CaseIterable { case box1 case box2 case box3 diff --git a/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift b/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift index 16bf659..69c27fa 100644 --- a/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift +++ b/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift @@ -21,8 +21,8 @@ final class ProgressSpinnerTests: XCTestCase { /// Test progress bar when writing to a non tty stream. func testSimpleProgresSpinner() { let outStream = BufferedOutputByteStream() - let spinner = Spinner(kind: oneOf(.box1, .bar1, .spin1)) - let isShowStopped = oneOf(true, false) + let spinner = Spinner(kind: Spinner.Kind.allCases.randomElement()!) + let isShowStopped = Bool.random() let progressSpinner = ProgressSpinnerKit.createProgressSpinner(forStream: outStream, header: "test", isShowStopped: isShowStopped, spinner: spinner) XCTAssertTrue(progressSpinner is SimpleProgressSpinner) @@ -45,8 +45,8 @@ final class ProgressSpinnerTests: XCTestCase { XCTFail("Couldn't create pseudo terminal.") return } - let spinner = Spinner(kind: oneOf(.box1, .bar1, .spin1)) - let isShowStopped = oneOf(true, false) + let spinner = Spinner(kind: Spinner.Kind.allCases.randomElement()!) + let isShowStopped = Bool.random() let progressSpinner = ProgressSpinnerKit.createProgressSpinner(forStream: pty.outStream, header: "TestHeader", isShowStopped: isShowStopped, spinner: spinner) XCTAssertTrue(progressSpinner is ProgressSpinner) @@ -96,10 +96,6 @@ final class ProgressSpinnerTests: XCTestCase { } -private func oneOf(_ items: T...) -> T { - return items[Int(arc4random_uniform(UInt32(items.count)))] -} - private final class PseudoTerminal { let master: Int32 let slave: Int32 From 75929b8df1fe298f027fd725b7bdf9fd8d0c1fd1 Mon Sep 17 00:00:00 2001 From: yutailang0119 Date: Tue, 2 Oct 2018 09:54:49 +0900 Subject: [PATCH 03/11] Update swift-package-manager via SwiftPM --- Package.resolved | 4 ++-- Package.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Package.resolved b/Package.resolved index 037e777..b2b7139 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/apple/swift-package-manager.git", "state": { "branch": null, - "revision": "6983434787dec4e543e9d398a0a9acf63ccd4da1", - "version": "0.2.1" + "revision": "235aacc514cb81a6881364b0fedcb3dd083228f3", + "version": "0.3.0" } } ] diff --git a/Package.swift b/Package.swift index 37fd73f..9d13430 100644 --- a/Package.swift +++ b/Package.swift @@ -9,7 +9,7 @@ let package = Package( .library(name: "ProgressSpinnerKit", targets: ["ProgressSpinnerKit"]), ], dependencies: [ - .package(url: "https://github.com/apple/swift-package-manager.git", from: "0.2.1"), + .package(url: "https://github.com/apple/swift-package-manager.git", from: "0.3.0"), ], targets: [ .target(name: "ProgressSpinnerKit", dependencies: ["Utility"]), From 7c3db9cb4c0ea4532f2405c8db85b2cf0dc93b91 Mon Sep 17 00:00:00 2001 From: yutailang0119 Date: Tue, 5 Feb 2019 14:42:21 +0900 Subject: [PATCH 04/11] Update swift-tools-version from 4.2 to 5.0 --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 9d13430..1cdc26f 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:4.2 +// swift-tools-version:5.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription From d6dcd6d85a2c30f6875119ec2442e81e70e71162 Mon Sep 17 00:00:00 2001 From: yutailang0119 Date: Wed, 24 Apr 2019 20:25:46 +0900 Subject: [PATCH 05/11] Update dependency version of SwiftPM to Swift 5.0 --- Package.resolved | 15 ++++++++++++--- Package.swift | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Package.resolved b/Package.resolved index b2b7139..f2e94e9 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,13 +1,22 @@ { "object": { "pins": [ + { + "package": "llbuild", + "repositoryURL": "https://github.com/apple/swift-llbuild.git", + "state": { + "branch": "master", + "revision": "d603a1641614065415d92af008fc60c1f1ea07ed", + "version": null + } + }, { "package": "SwiftPM", "repositoryURL": "https://github.com/apple/swift-package-manager.git", "state": { - "branch": null, - "revision": "235aacc514cb81a6881364b0fedcb3dd083228f3", - "version": "0.3.0" + "branch": "swift-5.0.1-RELEASE", + "revision": "3a57975e10be0b1a8b87992ddf3a49701036f96c", + "version": null } } ] diff --git a/Package.swift b/Package.swift index 1cdc26f..214f0ed 100644 --- a/Package.swift +++ b/Package.swift @@ -9,10 +9,10 @@ let package = Package( .library(name: "ProgressSpinnerKit", targets: ["ProgressSpinnerKit"]), ], dependencies: [ - .package(url: "https://github.com/apple/swift-package-manager.git", from: "0.3.0"), + .package(url: "https://github.com/apple/swift-package-manager.git", .revision("swift-5.0.1-RELEASE")), ], targets: [ - .target(name: "ProgressSpinnerKit", dependencies: ["Utility"]), + .target(name: "ProgressSpinnerKit", dependencies: ["SPMUtility"]), .testTarget(name: "ProgressSpinnerKitTests", dependencies: ["ProgressSpinnerKit"]), .target(name: "Demo", dependencies: ["ProgressSpinnerKit"]), ] From 3b042dc497bed1b6008ae84015e835b67daa5535 Mon Sep 17 00:00:00 2001 From: yutailang0119 Date: Wed, 24 Apr 2019 20:32:54 +0900 Subject: [PATCH 06/11] Fix to follow the interface changes of SwiftPM --- Sources/ProgressSpinnerKit/ProgressSpinner.swift | 2 +- Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/ProgressSpinnerKit/ProgressSpinner.swift b/Sources/ProgressSpinnerKit/ProgressSpinner.swift index dddb37f..0bfd7aa 100644 --- a/Sources/ProgressSpinnerKit/ProgressSpinner.swift +++ b/Sources/ProgressSpinnerKit/ProgressSpinner.swift @@ -7,7 +7,7 @@ import Foundation import Basic -import Utility +import SPMUtility private var fps: useconds_t { let fps: Double = 1 / 60 diff --git a/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift b/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift index 69c27fa..d3322d9 100644 --- a/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift +++ b/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift @@ -65,7 +65,7 @@ final class ProgressSpinnerTests: XCTestCase { thread.join() pty.closeMaster() - let chuzzledOutput = output.chuzzle()! + let chuzzledOutput = output.spm_chuzzle()! let prefix = "\u{1B}[2K" XCTAssertTrue(chuzzledOutput.hasPrefix(prefix)) let suffix = isShowStopped ? "\u{1B}[32m\u{1B}[1mStop\u{1B}[0m" : "" From e74692b36405baa4facf7eee2188df1cd2624bbe Mon Sep 17 00:00:00 2001 From: yutailang0119 Date: Fri, 3 May 2019 16:17:26 +0900 Subject: [PATCH 07/11] Fix test for updating SwiftPM --- Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift b/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift index d3322d9..8ac92d8 100644 --- a/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift +++ b/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift @@ -36,7 +36,7 @@ final class ProgressSpinnerTests: XCTestCase { let verificationFrames = (0.. Date: Thu, 30 May 2019 14:57:31 +0900 Subject: [PATCH 08/11] Cosmetic Fix of test --- .../ProgressSpinnerKitTests/ProgressSpinnerTests.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift b/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift index 8ac92d8..e62792d 100644 --- a/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift +++ b/Tests/ProgressSpinnerKitTests/ProgressSpinnerTests.swift @@ -23,7 +23,8 @@ final class ProgressSpinnerTests: XCTestCase { let outStream = BufferedOutputByteStream() let spinner = Spinner(kind: Spinner.Kind.allCases.randomElement()!) let isShowStopped = Bool.random() - let progressSpinner = ProgressSpinnerKit.createProgressSpinner(forStream: outStream, header: "test", isShowStopped: isShowStopped, spinner: spinner) + let headerText = "test" + let progressSpinner = ProgressSpinnerKit.createProgressSpinner(forStream: outStream, header: headerText, isShowStopped: isShowStopped, spinner: spinner) XCTAssertTrue(progressSpinner is SimpleProgressSpinner) let second = arc4random_uniform(10) @@ -33,7 +34,7 @@ final class ProgressSpinnerTests: XCTestCase { let frameCount = Int(ceil(Double(duration) / Double(fps * 100))) var verificationSpinner = spinner let verificationSuffix = isShowStopped ? "Stop\n" : "" - let verificationFrames = (0.. Date: Thu, 6 Jun 2019 08:55:10 -0700 Subject: [PATCH 09/11] Fix interface of createProgressSpinner for ThreadSafeOutputByteStream --- Sources/ProgressSpinnerKit/ProgressSpinner.swift | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Sources/ProgressSpinnerKit/ProgressSpinner.swift b/Sources/ProgressSpinnerKit/ProgressSpinner.swift index 0bfd7aa..2d5489a 100644 --- a/Sources/ProgressSpinnerKit/ProgressSpinner.swift +++ b/Sources/ProgressSpinnerKit/ProgressSpinner.swift @@ -181,9 +181,10 @@ final class ProgressSpinner: ProgressSpinnable { } /// Creates colored or simple progress spinner based on the provided output stream. -public func createProgressSpinner(forStream stream: OutputByteStream, header: String, isShowStopped: Bool = true, spinner: Spinner = Spinner(kind: .box1)) -> ProgressSpinnable { - guard let stdStream = stream as? LocalFileOutputByteStream else { - return SimpleProgressSpinner(stream: stream, header: header, isShowStopped: isShowStopped, spinner: spinner) +public func createProgressSpinner(forStream stderrStream: ThreadSafeOutputByteStream, header: String, isShowStopped: Bool = true, spinner: Spinner = Spinner(kind: .box1)) -> ProgressSpinnable { + + guard let stdStream = stderrStream.stream as? LocalFileOutputByteStream else { + return SimpleProgressSpinner(stream: stderrStream.stream, header: header, isShowStopped: isShowStopped, spinner: spinner) } // If we have a terminal, use animated progress spinener. @@ -193,9 +194,9 @@ public func createProgressSpinner(forStream stream: OutputByteStream, header: St // If the terminal is dumb, use single line progress spinner. if TerminalController.terminalType(stdStream) == .dumb { - return SingleLineProgressSpinnar(stream: stream, header: header, isShowStopped: isShowStopped, spinner: spinner) + return SingleLineProgressSpinnar(stream: stderrStream.stream, header: header, isShowStopped: isShowStopped, spinner: spinner) } // Use simple progress spinner by default. - return SimpleProgressSpinner(stream: stream, header: header, isShowStopped: isShowStopped, spinner: spinner) + return SimpleProgressSpinner(stream: stderrStream.stream, header: header, isShowStopped: isShowStopped, spinner: spinner) } From 6b855eeb4b40b4259364790cf1d1a2414b6f1d31 Mon Sep 17 00:00:00 2001 From: yutailang0119 Date: Thu, 6 Jun 2019 09:48:52 -0700 Subject: [PATCH 10/11] Fix a crash bug when use SimpleProgressSpinner --- .../ProgressSpinnerKit/ProgressSpinner.swift | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Sources/ProgressSpinnerKit/ProgressSpinner.swift b/Sources/ProgressSpinnerKit/ProgressSpinner.swift index 2d5489a..a28db50 100644 --- a/Sources/ProgressSpinnerKit/ProgressSpinner.swift +++ b/Sources/ProgressSpinnerKit/ProgressSpinner.swift @@ -56,7 +56,10 @@ final class SingleLineProgressSpinnar: ProgressSpinnable { self.stream <<< "Start..." self.stream <<< "\n" - queue.async { [unowned self] in + queue.async { [weak self] in + guard let self = self else { + return + } while self.isProgressing { self.stream <<< self.spinner.frame self.stream <<< "\n" @@ -108,7 +111,10 @@ final class SimpleProgressSpinner: ProgressSpinnable { isClear = false } - queue.async { [unowned self] in + queue.async { [weak self] in + guard let self = self else { + return + } while self.isProgressing { self.stream <<< self.spinner.frame self.stream <<< "\n" @@ -155,15 +161,18 @@ final class ProgressSpinner: ProgressSpinnable { isProgressing = true queue.async { [weak self] in - while self?.isProgressing ?? false { - self?.term.clearLine() - self?.term.write(self?.header ?? "", inColor: .green, bold: true) - self?.term.write(self?.spinner.frame ?? "", inColor: .green) - self?.term.endLine() + guard let self = self else { + return + } + while self.isProgressing { + self.term.clearLine() + self.term.write(self.header, inColor: .green, bold: true) + self.term.write(self.spinner.frame, inColor: .green) + self.term.endLine() - self?.term.moveCursor(up: 1) + self.term.moveCursor(up: 1) - usleep(self?.sleepInterval ?? 0) + usleep(self.sleepInterval) } } From 781d3eb14fe2d8b20e52076086914682da748da1 Mon Sep 17 00:00:00 2001 From: yutailang0119 Date: Thu, 6 Jun 2019 10:14:01 -0700 Subject: [PATCH 11/11] swift package update for swift-llbuild revision --- Package.resolved | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.resolved b/Package.resolved index f2e94e9..1301bac 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,7 +6,7 @@ "repositoryURL": "https://github.com/apple/swift-llbuild.git", "state": { "branch": "master", - "revision": "d603a1641614065415d92af008fc60c1f1ea07ed", + "revision": "3aeecb428d202afe15633266dc862de27feab723", "version": null } },