mirror of
https://github.com/dunglas/frankenphp.git
synced 2025-12-24 13:38:11 +08:00
Compare commits
4 Commits
feat/apach
...
fibers-tes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11da3be7e5 | ||
|
|
4ffb8c4793 | ||
|
|
890b7d12ac | ||
|
|
a98ca7f9de |
3
.github/workflows/docker.yaml
vendored
3
.github/workflows/docker.yaml
vendored
@@ -92,7 +92,6 @@ jobs:
|
||||
qemu: true
|
||||
- platform: linux/amd64
|
||||
qemu: false
|
||||
race: "-race" # The Go race detector is only supported on amd64
|
||||
- platform: linux/386
|
||||
qemu: false
|
||||
steps:
|
||||
@@ -182,7 +181,7 @@ jobs:
|
||||
run: |
|
||||
docker run --platform=${{ matrix.platform }} --rm \
|
||||
"$(jq -r '."builder-${{ matrix.variant }}"."containerimage.config.digest"' <<< "${METADATA}")" \
|
||||
sh -c 'go test ${{ matrix.race }} -v ./... && cd caddy && go test ${{ matrix.race }} -v ./...'
|
||||
sh -c 'CGO_CXXFLAGS=-fPIE CGO_CFLAGS=-fPIE CGO_LDFLAGS=-pie go test -buildmode=pie -v ./... && cd caddy && go test -buildmode=pie -v ./...'
|
||||
env:
|
||||
METADATA: ${{ steps.build.outputs.metadata }}
|
||||
# Adapted from https://docs.docker.com/build/ci/github-actions/multi-platform/
|
||||
|
||||
4
.github/workflows/tests.yaml
vendored
4
.github/workflows/tests.yaml
vendored
@@ -48,11 +48,11 @@ jobs:
|
||||
run: go build
|
||||
-
|
||||
name: Run library tests
|
||||
run: go test -race -v ./...
|
||||
run: CGO_CXXFLAGS=-fPIE CGO_CFLAGS=-fPIE CGO_LDFLAGS=-pie go test -buildmode=pie -v ./...
|
||||
-
|
||||
name: Run Caddy module tests
|
||||
working-directory: caddy/
|
||||
run: go test -race -v ./...
|
||||
run: CGO_CXXFLAGS=-fPIE CGO_CFLAGS=-fPIE CGO_LDFLAGS=-pie go test -buildmode=pie -v ./...
|
||||
-
|
||||
name: Lint Go code
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
|
||||
@@ -503,6 +503,23 @@ func testFlush(t *testing.T, opts *testOptions) {
|
||||
}, opts)
|
||||
}
|
||||
|
||||
func TestFiberBasic_module(t *testing.T) { testFiberBasic(t, &testOptions{}) }
|
||||
func TestFiberBasic_worker(t *testing.T) {
|
||||
testFiberBasic(t, &testOptions{workerScript: "fiber-basic.php"})
|
||||
}
|
||||
func testFiberBasic(t *testing.T, opts *testOptions) {
|
||||
runTest(t, func(handler func(http.ResponseWriter, *http.Request), _ *httptest.Server, i int) {
|
||||
req := httptest.NewRequest("GET", fmt.Sprintf("http://example.com/fiber-basic.php?i=%d", i), nil)
|
||||
w := httptest.NewRecorder()
|
||||
handler(w, req)
|
||||
|
||||
resp := w.Result()
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
|
||||
assert.Equal(t, string(body), fmt.Sprintf("Fiber %d", i))
|
||||
}, opts)
|
||||
}
|
||||
|
||||
func TestLargeRequest_module(t *testing.T) {
|
||||
testLargeRequest(t, &testOptions{})
|
||||
}
|
||||
|
||||
9
testdata/fiber-basic.php
vendored
Normal file
9
testdata/fiber-basic.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
require_once __DIR__.'/_executor.php';
|
||||
|
||||
return function() {
|
||||
$fiber = new Fiber(function() {
|
||||
echo 'Fiber '.($_GET['i'] ?? '');
|
||||
});
|
||||
$fiber->start();
|
||||
};
|
||||
Reference in New Issue
Block a user