Skip to content

Commit bab22d0

Browse files
tomerdartemredkin
authored andcommitted
test formatting issues as part of sanity check (#73)
motivaiton: unified format changes: * fix outstanding formatting issues * add a call to swiftformat as part of sanity script * fix sanity script language check debugging statements
1 parent 53d5bce commit bab22d0

File tree

6 files changed

+33
-13
lines changed

6 files changed

+33
-13
lines changed

.swiftformat

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# file options
22

3+
--exclude .build
4+
35
# format options
46

5-
--self insert
6-
--patternlet inline
7-
--stripunusedargs unnamed-only
7+
--self insert
8+
--patternlet inline
9+
--stripunusedargs unnamed-only
810
--comments ignore
911

1012
# rules

Sources/AsyncHTTPClient/HTTPHandler.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import NIOHTTP1
1919
import NIOSSL
2020

2121
extension HTTPClient {
22-
2322
/// Represent request body.
2423
public struct Body {
2524
/// Chunk provider.
@@ -333,7 +332,7 @@ extension HTTPClientResponseDelegate {
333332

334333
public func didSendRequest(task: HTTPClient.Task<Response>) {}
335334

336-
public func didReceiveHead(task: HTTPClient.Task<Response>, _: HTTPResponseHead) -> EventLoopFuture<Void> { return task.eventLoop.makeSucceededFuture(()) }
335+
public func didReceiveHead(task: HTTPClient.Task<Response>, _: HTTPResponseHead) -> EventLoopFuture<Void> { return task.eventLoop.makeSucceededFuture(()) }
337336

338337
public func didReceivePart(task: HTTPClient.Task<Response>, _: ByteBuffer) -> EventLoopFuture<Void> { return task.eventLoop.makeSucceededFuture(()) }
339338

Tests/AsyncHTTPClientTests/HTTPClientInternalTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,3 @@ class HTTPClientInternalTests: XCTestCase {
194194
XCTAssertEqual(delegate.reads, 3)
195195
}
196196
}
197-

Tests/AsyncHTTPClientTests/HTTPClientTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class HTTPClientTests: XCTestCase {
4444
let response = try httpClient.get(url: "http://localhost:\(httpBin.port)/get").wait()
4545
XCTAssertEqual(.ok, response.status)
4646
}
47-
47+
4848
func testGetWithSharedEventLoopGroup() throws {
4949
let httpBin = HttpBin()
5050
let elg = MultiThreadedEventLoopGroup(numberOfThreads: 8)
@@ -53,12 +53,12 @@ class HTTPClientTests: XCTestCase {
5353
try! elg.syncShutdownGracefully()
5454
httpBin.shutdown()
5555
}
56-
56+
5757
let delegate = TestHTTPDelegate()
5858
let request = try HTTPClient.Request(url: "http://localhost:\(httpBin.port)/events/10/1")
5959
let task = httpClient.execute(request: request, delegate: delegate)
6060
let expectedEventLoop = task.eventLoop
61-
task.futureResult.whenComplete { (_) in
61+
task.futureResult.whenComplete { _ in
6262
XCTAssertTrue(expectedEventLoop.inEventLoop)
6363
}
6464
try task.wait()
@@ -154,15 +154,15 @@ class HTTPClientTests: XCTestCase {
154154
let hostName = try decoder.decode([String: String].self, from: responseData)["data"]
155155
XCTAssert(hostName == "127.0.0.1")
156156
}
157-
157+
158158
func testPercentEncoded() throws {
159159
let httpBin = HttpBin()
160160
let httpClient = HTTPClient(eventLoopGroupProvider: .createNew)
161161
defer {
162162
try! httpClient.syncShutdown()
163163
httpBin.shutdown()
164164
}
165-
165+
166166
let response = try httpClient.get(url: "http://localhost:\(httpBin.port)/percent%20encoded").wait()
167167
XCTAssertEqual(.ok, response.status)
168168
}

docker/Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ RUN gem install jazzy --no-ri --no-rdoc
2323
RUN mkdir -p $HOME/.tools
2424
RUN echo 'export PATH="$HOME/.tools:$PATH"' >> $HOME/.profile
2525

26-
# script to allow mapping framepointers on linux
26+
# script to allow mapping framepointers on linux (until part of the toolchain)
2727
RUN wget -q https://raw.githubusercontent.com/apple/swift/master/utils/symbolicate-linux-fatal -O $HOME/.tools/symbolicate-linux-fatal
2828
RUN chmod 755 $HOME/.tools/symbolicate-linux-fatal
29+
30+
# swiftformat (until part of the toolchain)
31+
32+
ARG swiftformat_version=0.40.11
33+
RUN git clone --branch $swiftformat_version --depth 1 https://github.com/nicklockwood/SwiftFormat $HOME/.tools/swift-format
34+
RUN cd $HOME/.tools/swift-format && swift build -c release
35+
RUN ln -s $HOME/.tools/swift-format/.build/release/swiftformat $HOME/.tools/swiftformat

scripts/sanity.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,23 @@ else
2828
printf "\033[0;32mokay.\033[0m\n"
2929
fi
3030

31-
printf "=> Checking license headers... "
31+
printf "=> Checking format... "
32+
FIRST_OUT="$(git status --porcelain)"
33+
swiftformat . > /dev/null 2>&1
34+
SECOND_OUT="$(git status --porcelain)"
35+
if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then
36+
printf "\033[0;31mformatting issues!\033[0m\n"
37+
git --no-pager diff
38+
exit 1
39+
else
40+
printf "\033[0;32mokay.\033[0m\n"
41+
fi
42+
43+
printf "=> Checking license headers\n"
3244
tmp=$(mktemp /tmp/.async-http-client-sanity_XXXXXX)
3345

3446
for language in swift-or-c bash dtrace; do
47+
printf " * $language... "
3548
declare -a matching_files
3649
declare -a exceptions
3750
expections=( )

0 commit comments

Comments
 (0)