From 06e9ede65768072d83749ce840c14d47b951a3d2 Mon Sep 17 00:00:00 2001 From: richardo2016 Date: Wed, 17 Apr 2024 22:22:35 +0800 Subject: [PATCH] ci: fix port usage on ci. --- package.json | 1 + test/index.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 1772b87..78c6d39 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ }, "devDependencies": { "@fibjs/ci": "^2.7.1", + "@fibjs/detect-port": "^1.0.2", "@fibjs/types": "^0.35.0", "cross-env": "^5.2.0", "fib-pool": "^1.6.0", diff --git a/test/index.js b/test/index.js index e10f636..a07e5a3 100644 --- a/test/index.js +++ b/test/index.js @@ -15,6 +15,8 @@ const pool = require('fib-pool'); const util = require('util'); const coroutine = require('coroutine'); +const detect_port = require('@fibjs/detect-port'); + const { startServer, stopServer } = require('./spec_helper'); // the assertions before `wait()` might fail if the leading operations take too long to finish @@ -25,7 +27,7 @@ let wait = function (n = delay) { let url = { protocol: 'http', domain: '127.0.0.1', - port: 8080, + port: detect_port(), get ['host']() { return this.protocol + '://' + this.domain + ':' + this.port }, @@ -82,7 +84,7 @@ function session_test(description, opts, test_opts, _before, _after) { after(() => stopServer(srv)); it('server', () => { - ++url.port; + url.port = detect_port(); srv = new http.Server(url.port, [ session.cookie_filter, @@ -396,7 +398,7 @@ function session_test(description, opts, test_opts, _before, _after) { after(() => stopServer(srv)); it('server', () => { - ++url.port; + url.port = detect_port(); srv = new http.Server(url.port, [ session.cookie_filter, { @@ -468,7 +470,7 @@ function session_test(description, opts, test_opts, _before, _after) { after(() => stopServer(srv)); it('server', () => { - ++url.port; + url.port = detect_port(); srv = new http.Server(url.port, [ session.api_filter, { @@ -944,7 +946,7 @@ function session_test(description, opts, test_opts, _before, _after) { let srv; after(() => stopServer(srv)); it('check token', () => { - ++url.port; + url.port = detect_port(); srv = new http.Server(url.port, [ session.cookie_filter, (r) => { @@ -1054,7 +1056,7 @@ function session_test(description, opts, test_opts, _before, _after) { after(() => stopServer(srv)); it('server', () => { - ++url.port; + url.port = detect_port(); srv = new http.Server(url.port, [ (r) => { try {