From 00dfd64a86f5ee5053beeb02b868b7594f3dc597 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 6 Apr 2023 14:00:54 +0100 Subject: integration tests: Preserve unmocked time.monotonic() With monotonic() frozen, timers may fail to trigger. This caused problems after the new util.startup changes that moved the server-started event to a timer. The timer wouldn't trigger, the event didn't fire, and prosody would fail to daemonize. All the tests that depend on specific time behaviour are depending on wall clock time, so only mocking util.time.now() and os.time() fixes those. --- spec/scansion/prosody.cfg.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'spec/scansion/prosody.cfg.lua') diff --git a/spec/scansion/prosody.cfg.lua b/spec/scansion/prosody.cfg.lua index 8d0d76e1..0061635d 100644 --- a/spec/scansion/prosody.cfg.lua +++ b/spec/scansion/prosody.cfg.lua @@ -1,15 +1,14 @@ --luacheck: ignore --- Mock time functions to simplify tests +-- Mock time functions to simplify tests -- +local time = require "util.time"; function _G.os.time() return 1219439344; end -package.preload["util.time"] = function () - return { - now = function () return 1219439344.5; end; - monotonic = function () return 0.5; end; - } +function time.now() + return 1219439344.5; end +------------------------------------------- admins = { "admin@localhost" } -- cgit v1.2.3