mirror of
https://github.com/grumpycoders/pcsx-redux.git
synced 2024-05-16 19:11:04 -04:00
Adding Lua unit testing.
This commit is contained in:
parent
41c5d3a1bf
commit
255c5f7bfc
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -91,3 +91,6 @@
|
|||
[submodule "third_party/luacov"]
|
||||
path = third_party/luacov
|
||||
url = https://github.com/grumpycoders/luacov.git
|
||||
[submodule "third_party/luaunit"]
|
||||
path = third_party/luaunit
|
||||
url = https://github.com/bluebird75/luaunit.git
|
||||
|
|
|
@ -333,7 +333,7 @@ int pcsxMain(int argc, char **argv) {
|
|||
bool luacovEnabled = false;
|
||||
if (args.get<bool>("luacov")) {
|
||||
auto L = *emulator->m_lua;
|
||||
L.load("package.path = package.path .. ';./lua_modules/share/lua/5.1/?.lua;./third_party/luacov/src/?.lua'",
|
||||
L.load("package.path = package.path .. ';./lua_modules/share/lua/5.1/?.lua;../../../third_party/luacov/src/?.lua;./third_party/luacov/src/?.lua'",
|
||||
"internal:package.path.lua");
|
||||
try {
|
||||
L.load(R"(
|
||||
|
|
28
tests/lua/basic.lua
Normal file
28
tests/lua/basic.lua
Normal file
|
@ -0,0 +1,28 @@
|
|||
-- Copyright (C) 2024 PCSX-Redux authors
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 2 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program; if not, write to the
|
||||
-- Free Software Foundation, Inc.,
|
||||
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
local lu = require 'luaunit'
|
||||
|
||||
TestBasic = {}
|
||||
|
||||
function TestBasic:test_basic()
|
||||
lu.assertEquals(1, 1)
|
||||
end
|
||||
|
||||
local runner = lu.LuaUnit.new()
|
||||
runner:setOutputType 'text'
|
||||
PCSX.quit(runner:runSuite())
|
43
tests/pcsxrunner/lua.cc
Normal file
43
tests/pcsxrunner/lua.cc
Normal file
|
@ -0,0 +1,43 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2024 PCSX-Redux authors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "main/main.h"
|
||||
|
||||
static const char prefix[] = R"(
|
||||
os.exit = PCSX.quit
|
||||
package.path = package.path .. ';../../../third_party/luaunit/?.lua'
|
||||
package.path = package.path .. ';./third_party/luaunit/?.lua'
|
||||
package.path = package.path .. ';../../../tests/lua/?.lua'
|
||||
package.path = package.path .. ';./tests/lua/?.lua'
|
||||
)";
|
||||
|
||||
TEST(LuaBasic, Interpreter) {
|
||||
MainInvoker invoker("-no-ui", "-run", "-bios", "src/mips/openbios/openbios.bin", "-testmode", "-interpreter",
|
||||
"-luacov", "-exec", prefix, "-exec", "require 'basic'");
|
||||
int ret = invoker.invoke();
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
TEST(LuaBasic, Dynarec) {
|
||||
MainInvoker invoker("-no-ui", "-run", "-bios", "src/mips/openbios/openbios.bin", "-testmode", "-dynarec", "-luacov",
|
||||
"-exec", prefix, "-exec", "require 'basic'");
|
||||
int ret = invoker.invoke();
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
1
third_party/luaunit
vendored
Submodule
1
third_party/luaunit
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 86f68228d73345dabd62a9596feac1f8f8fcaca2
|
|
@ -97,6 +97,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "supportpsx", "supportpsx\su
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lpeg", "lpeg\lpeg.vcxproj", "{CE54ED92-4645-4AE9-BDC8-C0B9607765F8}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Lua", "Lua", "{394627A0-57EB-46B1-B768-E02ACFC798A8}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
..\tests\lua\basic.lua = ..\tests\lua\basic.lua
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
|
@ -530,9 +535,10 @@ Global
|
|||
{CDED480F-14EE-475E-97F5-97F2B62DB3CE} = {C6DD47BC-0C38-4AE6-B517-9675F3AC8A50}
|
||||
{B2E2AD84-9D7F-4976-9572-E415819FFD7F} = {008A2872-432F-480B-828D-FF9AAA4846BC}
|
||||
{CE54ED92-4645-4AE9-BDC8-C0B9607765F8} = {64A05F50-3203-42CC-B632-09D6EE6EA856}
|
||||
{394627A0-57EB-46B1-B768-E02ACFC798A8} = {9D5A1DB2-E74D-4CDD-8377-9EA08CF4AADE}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {AC54A867-F976-4B3D-A6EF-F57EB764DCD4}
|
||||
SolutionGuid = {284E91C1-764E-441A-854D-CFD3623A6501}
|
||||
SolutionGuid = {AC54A867-F976-4B3D-A6EF-F57EB764DCD4}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -389,6 +389,7 @@
|
|||
<ClCompile Include="..\..\..\tests\pcsxrunner\dma.cc" />
|
||||
<ClCompile Include="..\..\..\tests\pcsxrunner\dumpproto.cc" />
|
||||
<ClCompile Include="..\..\..\tests\pcsxrunner\libc.cc" />
|
||||
<ClCompile Include="..\..\..\tests\pcsxrunner\lua.cc" />
|
||||
<ClCompile Include="..\..\..\tests\pcsxrunner\pcdrv.cc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
<ClCompile Include="..\..\..\tests\pcsxrunner\dma.cc">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\tests\pcsxrunner\lua.cc">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
|
Loading…
Reference in a new issue