From 9e1d31fc2a64567bae65e52c1ca48f87322b3ce0 Mon Sep 17 00:00:00 2001 From: Ryan Ward Date: Tue, 25 Apr 2023 22:32:24 -0400 Subject: [PATCH] Modified tests to make it more seamless --- README.md | 10 ++++++++-- tests/main.lua | 7 ++++++- tests/runtests.lua | 25 ++++++++++++++++--------- tests/threadtests.lua | 6 ++++++ 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 05897c2..a5a5248 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Multi Version: 16.0.0 +# Multi Version: 16.0.0 Connecting the dots **Key Changes** - Concat connections @@ -34,12 +34,18 @@ https://discord.gg/U8UspuA Planned features/TODO --------------------- -- [ ] Create test suite (In progress, mostly done) +- [x] Create test suite (In progress, mostly done) - [ ] Network Parallelism rework Usage: [Check out the documentation for more info](https://github.com/rayaman/multi/blob/master/Documentation.md) ----- +You can run tests in 2 ways: +``` +lua tests/runtests.lua (Runs all tests, attempts to use lanes) +love tests (Runs all tests in love2d env) +``` + ```lua local multi, thread = require("multi"):init() GLOBAL, THREAD = require("multi.integration.threading"):init() diff --git a/tests/main.lua b/tests/main.lua index 768ce1c..232899c 100644 --- a/tests/main.lua +++ b/tests/main.lua @@ -1,2 +1,7 @@ +require("runtests") require("threadtests") --- Allows you to run "love tests" which runs the tests \ No newline at end of file +-- Allows you to run "love tests" which runs the tests + +function love.update() + multi:uManager() +end \ No newline at end of file diff --git a/tests/runtests.lua b/tests/runtests.lua index ae8b098..ff59c52 100644 --- a/tests/runtests.lua +++ b/tests/runtests.lua @@ -22,7 +22,10 @@ end ]] local multi, thread = require("multi"):init{print=true}--{priority=true} local good = false -local proc = multi:newProcessor("Test",true) +local proc = multi:newProcessor("Test") + +proc.Start() + proc:newAlarm(3):OnRing(function() good = true end) @@ -163,23 +166,27 @@ runTest = thread:newFunction(function() end c3 = false c4 = false - d:Destroy() + conn3:Unconnect(d) conn3:Fire() if c3 and not(c4) then print("Connection Test 3: Ok") else print("Connection Test 3: Error removing connection") end - os.exit() -- End of tests + if not love then + print("Testing pseudo threading") + os.execute("lua tests/threadtests.lua p") + print("Testing lanes threading") + os.execute("lua tests/threadtests.lua l") + os.exit() + end end) -print(runTest().OnError(function(...) +runTest().OnError(function(...) print("Error: Something went wrong with the test!") print(...) - os.exit(1) -end)) +end) -print("Pumping proc") -while true do - proc.run() +if not love then + multi:mainloop() end \ No newline at end of file diff --git a/tests/threadtests.lua b/tests/threadtests.lua index 52dd112..fd2e735 100644 --- a/tests/threadtests.lua +++ b/tests/threadtests.lua @@ -7,6 +7,12 @@ local env if love then GLOBAL, THREAD = require("multi.integration.loveManager"):init() env = LOVE +elseif arg[1] == "l" then + GLOBAL, THREAD = require("multi.integration.lanesManager"):init() + env = LANES +elseif arg[1] == "p" then + GLOBAL, THREAD = require("multi.integration.pseudoManager"):init() + env = PSEUDO else io.write("Test Pseudo(p), Lanes(l), or love(Run in love environment) Threading: ") choice = io.read()