Tests: serve the network tests from a loopback HTTP server - #249
Open
matthargett wants to merge 2 commits into
Open
matthargett wants to merge 2 commits into
matthargett wants to merge 2 commits into
Conversation
The XMLHttpRequest and fetch suites fetched https://github.com/ and a mesh from raw.githubusercontent.com to check status codes, statusText, percent-encoding of non-ASCII paths and abort-in-flight. Any hiccup on those hosts (or a runner without outbound network) failed the run, as the 504s on the recent upstream reruns showed. The test host now starts a small HTTP/1.1 server on 127.0.0.1 with an ephemeral port and publishes its origin to the scripts as the `hostTestServer` global. It answers "/" with 200, unknown paths with 404 "Not Found", "/assets/<name>" with 200 only when the request-target decodes to the expected UTF-8 file name (so the client's own encoding is what gets checked), and "/delay/<ms>" after a delay so the abort tests are guaranteed to abort a request that is still in flight. The connection-refused tests keep using 127.0.0.1:1. Plain sockets on every platform (Winsock on Windows, poll-driven accept loop, MSG_NOSIGNAL/SO_NOSIGPIPE for clients that go away mid-request); the Android test library links it too.
…opback test server
Author
|
Fork twin caught the Android side: UrlLib there goes through |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The XMLHttpRequest and fetch suites hit
https://github.com/andraw.githubusercontent.comto check status codes,statusText, percent-encoding of non-ASCII paths and abort-in-flight behaviour. Any hiccup on those hosts fails the run — the recent upstream reruns of #116 went red on external 504s (httpbin.org, github.com) with the same commit green elsewhere — and a runner without outbound network cannot run the suite at all.Change
The test host starts a small loopback HTTP/1.1 server (
Tests/UnitTests/Shared/TestHttpServer.{h,cpp}, plain sockets, Winsock on Windows) on127.0.0.1with an ephemeral port and hands its origin to the scripts as thehostTestServerglobal. Routes, matched after percent-decoding the request-target:/OK/assets/<name><name>decodes toστρογγυλεμένος % κύβος.glb— the client's own encoding is what gets exercised; anything else 404/delay/<ms>Not FoundEvery response is
text/plainwithConnection: close.tests.tskeeps its assertions and just takes the URLs from atestServertable; the connection-refused tests still use127.0.0.1:1. The Android test library (UnitTestsJNI) links the server too. No polyfill code changes.Verified on macOS (JavaScriptCore): 225 passing / 3 pending in the JavaScript suite,
UnitTests23/23. Fork twin: rebeckerspecialties#33.