diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9541332..dedbb1d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -7,22 +7,15 @@ jobs: name: Swift ${{ matrix.swift }} on ${{ matrix.os }} strategy: matrix: - # os: [ubuntu-latest, macos-latest] - os: [ubuntu-latest] - # swift: ["5.8", "5.9"] - swift: ["5.9"] + os: [ubuntu-latest, macos-latest] + swift: ["5.8", "5.9"] runs-on: ${{ matrix.os }} steps: - uses: swift-actions/setup-swift@v1 with: swift-version: ${{ matrix.swift }} - uses: actions/checkout@v4 - - name: Test Server - run: | - make setup_server - curl 127.0.0.1:8080 - make teardown_server - # - name: Build - # run: swift build - # - name: Run tests - # run: swift test --skip IntegrationTests + - name: Run Unit Tests + run: make unit_test + - name: Run Integration Tests + run: make integration_test diff --git a/Makefile b/Makefile index 649da11..5caf524 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,8 @@ setup_server: server_environment .PHONY: teardown_server teardown_server: - kill -9 $(ps -ef | grep "$(RUN_FLASK)" | grep -v "grep" | awk '{print $2}') + kill -9 $$(lsof -t -i :$(SERVER_PORT)) + ######### Production ######### .PHONY: release @@ -20,10 +21,22 @@ release: test .PHONY: test test: + make unit_test + make integration_test + +.PHONY: unit_test +unit_test: + swift test --skip IntegrationTests + +.PHONY: integration_test +integration_test: make setup_server - swift test --parallel -Xswiftc -DINTEGRATION_TEST + sleep 5 + curl http://localhost:8080 + swift test -Xswiftc -DINTEGRATION_TEST --filter IntegrationTests || true make teardown_server + .PHONY: package package: echo "make package is not implemented" @@ -35,7 +48,7 @@ debug_build: .PHONY: debug_unit_test debug_unit_test: - swift test --skip IntegrationTests + swift test -Xswiftc -DDEBUG --skip IntegrationTests .PHONY: debug_integration_test debug_integration_test: diff --git a/Mock/app.py b/Mock/app.py index bc1f093..725092c 100644 --- a/Mock/app.py +++ b/Mock/app.py @@ -36,7 +36,7 @@ def _generate_response(desired_status_code) -> Response: desired_status_code = int(desired_status_code) except: return make_response("Invalid Status-Code in the HTTP Header", 404) - response = make_response("Hello from lcl-ping mock server!") + response = make_response("Hello from lcl-ping mock server!\n") response.status_code = desired_status_code return response diff --git a/Sources/LCLPing/HTTP/HTTPPing.swift b/Sources/LCLPing/HTTP/HTTPPing.swift index 35894a6..e82482b 100644 --- a/Sources/LCLPing/HTTP/HTTPPing.swift +++ b/Sources/LCLPing/HTTP/HTTPPing.swift @@ -197,10 +197,6 @@ internal struct HTTPPing: Pingable { case .finished, .ready, .error: fatalError("wrong state: \(pingStatus)") } - - if let pingSummary = pingSummary { - printSummary(pingSummary) - } } catch { pingStatus = .error throw PingError.sendPingFailed(error) diff --git a/Sources/LCLPing/ICMP/ICMPPing.swift b/Sources/LCLPing/ICMP/ICMPPing.swift index 3456cfb..51630ec 100644 --- a/Sources/LCLPing/ICMP/ICMPPing.swift +++ b/Sources/LCLPing/ICMP/ICMPPing.swift @@ -159,11 +159,6 @@ internal struct ICMPPing: Pingable { if self.pingStatus != .stopped { pingStatus = .finished } - - if let pingSummary = pingSummary { - printSummary(pingSummary) - } - case .failure(let failure): pingStatus = .error throw failure