Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [next/testing Lua modules 01/11] luarocks: add generation of test
@ 2019-02-19 15:43 Francois Perrad
  2019-02-19 15:43 ` [Buildroot] [next/testing Lua modules 02/11] support/testing: add lpeg test Francois Perrad
                   ` (10 more replies)
  0 siblings, 11 replies; 14+ messages in thread
From: Francois Perrad @ 2019-02-19 15:43 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
---
 package/luarocks/buildroot.lua | 60 ++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/package/luarocks/buildroot.lua b/package/luarocks/buildroot.lua
index 4be5fbd7c..61e44a867 100644
--- a/package/luarocks/buildroot.lua
+++ b/package/luarocks/buildroot.lua
@@ -49,6 +49,27 @@ local function wrap (txt, max)
    return lines
 end
 
+local function has_c_files (rockspec)
+   for _, mod in pairs(rockspec.build.modules or {}) do
+      if type(mod) == 'string' then
+         if mod:match'%.c$' then
+            return true
+         end
+      elseif type(mod) == 'table' then
+         local sources = mod.sources
+         if type(sources) == 'string' and sources:match'%.c$' then
+            return true
+         end
+         for _, src in ipairs(sources or mod) do
+            if src:match'%.c$' then
+               return true
+            end
+         end
+      end
+   end
+   return false
+end
+
 local function get_external_dependencies (rockspec)
    local t = {}
    for k in pairs(rockspec.external_dependencies or {}) do
@@ -228,6 +249,42 @@ local function generate_hash (rockspec, lcname, rock_file, licenses, digest)
    f:close()
 end
 
+local function generate_test (rockspec, lcname)
+   local ucname = brname(lcname)
+   local modname = rockspec.package:gsub('%-', '')
+   local classname = modname:gsub('%.', '')
+   classname = classname:sub(1, 1):upper() .. classname:sub(2)
+   local fname = 'support/testing/tests/package/test_' .. ucname:lower() .. '.py'
+   local f = assert(io.open(fname, 'w'))
+   util.printout('write ' .. fname)
+   f:write('from tests.package.test_lua import TestLuaBase\n')
+   f:write('\n')
+   f:write('\n')
+   f:write('class TestLua' .. classname .. '(TestLuaBase):\n')
+   f:write('    config = TestLuaBase.config + \\\n')
+   f:write('        """\n')
+   f:write('        BR2_PACKAGE_LUA=y\n')
+   f:write('        BR2_PACKAGE_' .. ucname .. '=y\n')
+   f:write('        """\n')
+   f:write('\n')
+   f:write('    def test_run(self):\n')
+   f:write('        self.login()\n')
+   f:write('        self.module_test("' .. modname .. '")\n')
+   f:write('\n')
+   f:write('\n')
+   f:write('class TestLuajit' .. classname .. '(TestLuaBase):\n')
+   f:write('    config = TestLuaBase.config + \\\n')
+   f:write('        """\n')
+   f:write('        BR2_PACKAGE_LUAJIT=y\n')
+   f:write('        BR2_PACKAGE_' .. ucname .. '=y\n')
+   f:write('        """\n')
+   f:write('\n')
+   f:write('    def test_run(self):\n')
+   f:write('        self.login()\n')
+   f:write('        self.module_test("' .. modname .. '")\n')
+   f:close()
+end
+
 --- Driver function for the "buildroot" command.
 -- @param rockname string: the name of a rock to be fetched and unpacked.
 -- @param brname string: the name used by Buildroot (optional)
@@ -319,6 +376,9 @@ function buildroot.command(flags, rockname, fsname)
    generate_config(rockspec, fsname:lower())
    generate_mk(rockspec, fsname:lower(), licenses)
    generate_hash(rockspec, fsname:lower(), rock_file, licenses, digest)
+   if has_c_files(rockspec) then
+      generate_test(rockspec, fsname:lower())
+   end
 
    return true
 end
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-03-28 17:22 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-19 15:43 [Buildroot] [next/testing Lua modules 01/11] luarocks: add generation of test Francois Perrad
2019-02-19 15:43 ` [Buildroot] [next/testing Lua modules 02/11] support/testing: add lpeg test Francois Perrad
2019-02-19 15:43 ` [Buildroot] [next/testing Lua modules 03/11] support/testing: add lsqlite3 test Francois Perrad
2019-02-19 15:43 ` [Buildroot] [next/testing Lua modules 04/11] support/testing: add lua-curl test Francois Perrad
2019-02-19 15:43 ` [Buildroot] [next/testing Lua modules 05/11] support/testing: add lua-utf8 test Francois Perrad
2019-02-19 15:43 ` [Buildroot] [next/testing Lua modules 06/11] support/testing: add luaexpat test Francois Perrad
2019-02-19 15:43 ` [Buildroot] [next/testing Lua modules 07/11] support/testing: add luafilesystem test Francois Perrad
2019-02-19 15:43 ` [Buildroot] [next/testing Lua modules 08/11] support/testing: add luaossl test Francois Perrad
2019-02-19 15:43 ` [Buildroot] [next/testing Lua modules 09/11] support/testing: add luasec test Francois Perrad
2019-02-19 15:43 ` [Buildroot] [next/testing Lua modules 10/11] support/testing: add luasocket test Francois Perrad
2019-02-19 15:43 ` [Buildroot] [next/testing Lua modules 11/11] support/testing: add rings test Francois Perrad
2019-03-28 16:22 ` [Buildroot] [next/testing Lua modules 01/11] luarocks: add generation of test Thomas Petazzoni
2019-03-28 17:13   ` François Perrad
2019-03-28 17:22     ` Thomas Petazzoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox