Skip to content

test formatting issues as part of sanity check #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# file options

--exclude .build

# format options

--self insert
--patternlet inline
--stripunusedargs unnamed-only
--self insert
--patternlet inline
--stripunusedargs unnamed-only
--comments ignore

# rules
3 changes: 1 addition & 2 deletions Sources/AsyncHTTPClient/HTTPHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import NIOHTTP1
import NIOSSL

extension HTTPClient {

/// Represent request body.
public struct Body {
/// Chunk provider.
Expand Down Expand Up @@ -333,7 +332,7 @@ extension HTTPClientResponseDelegate {

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

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

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

Expand Down
1 change: 0 additions & 1 deletion Tests/AsyncHTTPClientTests/HTTPClientInternalTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,3 @@ class HTTPClientInternalTests: XCTestCase {
XCTAssertEqual(delegate.reads, 3)
}
}

10 changes: 5 additions & 5 deletions Tests/AsyncHTTPClientTests/HTTPClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class HTTPClientTests: XCTestCase {
let response = try httpClient.get(url: "http://localhost:\(httpBin.port)/get").wait()
XCTAssertEqual(.ok, response.status)
}

func testGetWithSharedEventLoopGroup() throws {
let httpBin = HttpBin()
let elg = MultiThreadedEventLoopGroup(numberOfThreads: 8)
Expand All @@ -53,12 +53,12 @@ class HTTPClientTests: XCTestCase {
try! elg.syncShutdownGracefully()
httpBin.shutdown()
}

let delegate = TestHTTPDelegate()
let request = try HTTPClient.Request(url: "http://localhost:\(httpBin.port)/events/10/1")
let task = httpClient.execute(request: request, delegate: delegate)
let expectedEventLoop = task.eventLoop
task.futureResult.whenComplete { (_) in
task.futureResult.whenComplete { _ in
XCTAssertTrue(expectedEventLoop.inEventLoop)
}
try task.wait()
Expand Down Expand Up @@ -154,15 +154,15 @@ class HTTPClientTests: XCTestCase {
let hostName = try decoder.decode([String: String].self, from: responseData)["data"]
XCTAssert(hostName == "127.0.0.1")
}

func testPercentEncoded() throws {
let httpBin = HttpBin()
let httpClient = HTTPClient(eventLoopGroupProvider: .createNew)
defer {
try! httpClient.syncShutdown()
httpBin.shutdown()
}

let response = try httpClient.get(url: "http://localhost:\(httpBin.port)/percent%20encoded").wait()
XCTAssertEqual(.ok, response.status)
}
Expand Down
9 changes: 8 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ RUN gem install jazzy --no-ri --no-rdoc
RUN mkdir -p $HOME/.tools
RUN echo 'export PATH="$HOME/.tools:$PATH"' >> $HOME/.profile

# script to allow mapping framepointers on linux
# script to allow mapping framepointers on linux (until part of the toolchain)
RUN wget -q https://raw.githubusercontent.com/apple/swift/master/utils/symbolicate-linux-fatal -O $HOME/.tools/symbolicate-linux-fatal
RUN chmod 755 $HOME/.tools/symbolicate-linux-fatal

# swiftformat (until part of the toolchain)

ARG swiftformat_version=0.40.11
RUN git clone --branch $swiftformat_version --depth 1 https://github.com/nicklockwood/SwiftFormat $HOME/.tools/swift-format
RUN cd $HOME/.tools/swift-format && swift build -c release
RUN ln -s $HOME/.tools/swift-format/.build/release/swiftformat $HOME/.tools/swiftformat
15 changes: 14 additions & 1 deletion scripts/sanity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,23 @@ else
printf "\033[0;32mokay.\033[0m\n"
fi

printf "=> Checking license headers... "
printf "=> Checking format... "
FIRST_OUT="$(git status --porcelain)"
swiftformat . > /dev/null 2>&1
SECOND_OUT="$(git status --porcelain)"
if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then
printf "\033[0;31mformatting issues!\033[0m\n"
git --no-pager diff
exit 1
else
printf "\033[0;32mokay.\033[0m\n"
fi

printf "=> Checking license headers\n"
tmp=$(mktemp /tmp/.async-http-client-sanity_XXXXXX)

for language in swift-or-c bash dtrace; do
printf " * $language... "
declare -a matching_files
declare -a exceptions
expections=( )
Expand Down