-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(socket): work without luasocket, using luasystem instead (#171)
All we need for the core scheduling tasks is: - a `sleep` function for a non-busy-loop wait - a `gettime` function to get actual time at usecond So without using sockets, luasystem should be good enough. Removing LuaSocket from the rockspec is a breaking change, hence it is still installed by default. To be reviewed in a next major.
- Loading branch information
Showing
16 changed files
with
155 additions
and
71 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
-- make sure we are pointing to the local copas first | ||
package.path = string.format("../src/?.lua;%s", package.path) | ||
|
||
print([[ | ||
Testing to run Copas without LuaSocket, just LuaSystem | ||
============================================================================= | ||
]]) | ||
|
||
-- patch require to no longer load luasocket | ||
local _require = require | ||
_G.require = function(name) | ||
if name == "socket" then | ||
error("luasocket is not allowed in this test") | ||
end | ||
return _require(name) | ||
end | ||
|
||
|
||
local copas = require "copas" | ||
local timer = copas.timer | ||
|
||
local successes = 0 | ||
|
||
local t1 -- luacheck: ignore | ||
|
||
copas.loop(function() | ||
|
||
t1 = timer.new({ | ||
delay = 0.1, | ||
recurring = true, | ||
callback = function(timer_obj, params) | ||
successes = successes + 1 -- 6 to come | ||
if successes == 6 then | ||
timer_obj:cancel() | ||
end | ||
end, | ||
}) | ||
-- succes count = 6 | ||
|
||
end) | ||
|
||
|
||
assert(successes == 6, "number of successes didn't match! got: "..successes) | ||
print("test success!") |
Oops, something went wrong.