Better cycling through httpd.js ports to avoid CI failures
This commit is contained in:
parent
a376ad8762
commit
be1ab236c8
2 changed files with 10 additions and 8 deletions
|
@ -328,8 +328,9 @@ describe("Zotero.Attachments", function() {
|
|||
Components.utils.import("resource://gre/modules/FileUtils.jsm");
|
||||
Components.utils.import("resource://zotero-unit/httpd.js");
|
||||
var testServerPath, httpd, prefix;
|
||||
var testServerPort = 16213;
|
||||
var maxTestServerPort = testServerPort + 10;
|
||||
var testServerPortMin = 16213;
|
||||
var testServerPortMax = testServerPort + 20;
|
||||
var testServerPort = testServerPortMin;
|
||||
|
||||
before(async function () {
|
||||
this.timeout(20000);
|
||||
|
@ -339,11 +340,11 @@ describe("Zotero.Attachments", function() {
|
|||
beforeEach(function () {
|
||||
// Cycle through ports to prevent NS_ERROR_SOCKET_ADDRESS_IN_USE errors from server
|
||||
// not always fully stopping in time
|
||||
if (testServerPort < maxTestServerPort) {
|
||||
if (testServerPort < testServerPortMax) {
|
||||
testServerPort++;
|
||||
}
|
||||
else {
|
||||
testServerPort--;
|
||||
testServerPort = testServerPortMin;
|
||||
}
|
||||
// Use random prefix because httpd does not actually stop between tests
|
||||
prefix = Zotero.Utilities.randomString();
|
||||
|
|
|
@ -143,8 +143,9 @@ describe("ZoteroPane", function() {
|
|||
describe("#viewAttachment", function () {
|
||||
Components.utils.import("resource://zotero-unit/httpd.js");
|
||||
var apiKey = Zotero.Utilities.randomString(24);
|
||||
var testServerPort = 16213;
|
||||
var maxTestServerPort = testServerPort + 10;
|
||||
var testServerPortMin = 16213;
|
||||
var testServerPortMax = testServerPort + 20;
|
||||
var testServerPort = testServerPortMin;
|
||||
var baseURL;
|
||||
var httpd;
|
||||
|
||||
|
@ -204,11 +205,11 @@ describe("ZoteroPane", function() {
|
|||
beforeEach(function* () {
|
||||
// Cycle through ports to prevent NS_ERROR_SOCKET_ADDRESS_IN_USE errors from server
|
||||
// not always fully stopping in time
|
||||
if (testServerPort < maxTestServerPort) {
|
||||
if (testServerPort < testServerPortMax) {
|
||||
testServerPort++;
|
||||
}
|
||||
else {
|
||||
testServerPort--;
|
||||
testServerPort = testServerPortMin;
|
||||
}
|
||||
baseURL = `http://localhost:${testServerPort}/`;
|
||||
Zotero.Prefs.set("api.url", baseURL);
|
||||
|
|
Loading…
Add table
Reference in a new issue