All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] package/luarocks: better choice of modules in generated test
@ 2019-03-31  6:48 Francois Perrad
  2019-03-31  6:48 ` [Buildroot] [PATCH 2/2] support/testing/tests/package/test_lua*: regeneration Francois Perrad
  2019-03-31 10:15 ` [Buildroot] [PATCH 1/2] package/luarocks: better choice of modules in generated test Thomas Petazzoni
  0 siblings, 2 replies; 3+ messages in thread
From: Francois Perrad @ 2019-03-31  6:48 UTC (permalink / raw)
  To: buildroot

the name derived from package name is not suitable,
so, we search in the built modules.

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

diff --git a/package/luarocks/buildroot.lua b/package/luarocks/buildroot.lua
index 61e44a867..39f0fe759 100644
--- a/package/luarocks/buildroot.lua
+++ b/package/luarocks/buildroot.lua
@@ -70,6 +70,25 @@ local function has_c_files (rockspec)
    return false
 end
 
+local function get_main_modules (rockspec)
+   local t = {}
+   for name in pairs(rockspec.build.modules or {}) do
+      if not name:match('%.') then
+         t[#t+1] = name
+      end
+   end
+   if #t == 0 then
+      for name in pairs(rockspec.build.modules or {}) do
+         t[#t+1] = name
+      end
+   end
+   if #t == 0 then
+      t[#t+1] = rockspec.package:gsub('%-', '')
+   end
+   table.sort(t)
+   return t
+end
+
 local function get_external_dependencies (rockspec)
    local t = {}
    for k in pairs(rockspec.external_dependencies or {}) do
@@ -251,9 +270,9 @@ end
 
 local function generate_test (rockspec, lcname)
    local ucname = brname(lcname)
-   local modname = rockspec.package:gsub('%-', '')
-   local classname = modname:gsub('%.', '')
+   local classname = rockspec.package:gsub('%-', ''):gsub('%.', '')
    classname = classname:sub(1, 1):upper() .. classname:sub(2)
+   local modnames = get_main_modules(rockspec)
    local fname = 'support/testing/tests/package/test_' .. ucname:lower() .. '.py'
    local f = assert(io.open(fname, 'w'))
    util.printout('write ' .. fname)
@@ -269,7 +288,9 @@ local function generate_test (rockspec, lcname)
    f:write('\n')
    f:write('    def test_run(self):\n')
    f:write('        self.login()\n')
-   f:write('        self.module_test("' .. modname .. '")\n')
+   for i = 1, #modnames do
+      f:write('        self.module_test("' .. modnames[i] .. '")\n')
+   end
    f:write('\n')
    f:write('\n')
    f:write('class TestLuajit' .. classname .. '(TestLuaBase):\n')
@@ -281,7 +302,9 @@ local function generate_test (rockspec, lcname)
    f:write('\n')
    f:write('    def test_run(self):\n')
    f:write('        self.login()\n')
-   f:write('        self.module_test("' .. modname .. '")\n')
+   for i = 1, #modnames do
+      f:write('        self.module_test("' .. modnames[i] .. '")\n')
+   end
    f:close()
 end
 
-- 
2.17.1

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

* [Buildroot] [PATCH 2/2] support/testing/tests/package/test_lua*: regeneration
  2019-03-31  6:48 [Buildroot] [PATCH 1/2] package/luarocks: better choice of modules in generated test Francois Perrad
@ 2019-03-31  6:48 ` Francois Perrad
  2019-03-31 10:15 ` [Buildroot] [PATCH 1/2] package/luarocks: better choice of modules in generated test Thomas Petazzoni
  1 sibling, 0 replies; 3+ messages in thread
From: Francois Perrad @ 2019-03-31  6:48 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
---
 support/testing/tests/package/test_lpeg.py      | 6 ++++--
 support/testing/tests/package/test_lua_curl.py  | 2 ++
 support/testing/tests/package/test_luaossl.py   | 2 ++
 support/testing/tests/package/test_luasocket.py | 4 ++++
 4 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/support/testing/tests/package/test_lpeg.py b/support/testing/tests/package/test_lpeg.py
index e57415735..4e1ee343b 100644
--- a/support/testing/tests/package/test_lpeg.py
+++ b/support/testing/tests/package/test_lpeg.py
@@ -10,7 +10,8 @@ class TestLuaLPeg(TestLuaBase):
 
     def test_run(self):
         self.login()
-        self.module_test("lpeg", script="print(require[[lpeg]].version())")
+        self.module_test("lpeg")
+        self.module_test("re")
 
 
 class TestLuajitLPeg(TestLuaBase):
@@ -22,4 +23,5 @@ class TestLuajitLPeg(TestLuaBase):
 
     def test_run(self):
         self.login()
-        self.module_test("lpeg", script="print(require[[lpeg]].version())")
+        self.module_test("lpeg")
+        self.module_test("re")
diff --git a/support/testing/tests/package/test_lua_curl.py b/support/testing/tests/package/test_lua_curl.py
index 5ee79313f..081303948 100644
--- a/support/testing/tests/package/test_lua_curl.py
+++ b/support/testing/tests/package/test_lua_curl.py
@@ -11,6 +11,7 @@ class TestLuaLuacURL(TestLuaBase):
     def test_run(self):
         self.login()
         self.module_test("cURL")
+        self.module_test("lcurl")
 
 
 class TestLuajitLuacURL(TestLuaBase):
@@ -23,3 +24,4 @@ class TestLuajitLuacURL(TestLuaBase):
     def test_run(self):
         self.login()
         self.module_test("cURL")
+        self.module_test("lcurl")
diff --git a/support/testing/tests/package/test_luaossl.py b/support/testing/tests/package/test_luaossl.py
index f6914e054..f9f9ab4ee 100644
--- a/support/testing/tests/package/test_luaossl.py
+++ b/support/testing/tests/package/test_luaossl.py
@@ -11,6 +11,7 @@ class TestLuaLuaossl(TestLuaBase):
     def test_run(self):
         self.login()
         self.module_test("openssl")
+        self.module_test("_openssl")
 
 
 class TestLuajitLuaossl(TestLuaBase):
@@ -23,3 +24,4 @@ class TestLuajitLuaossl(TestLuaBase):
     def test_run(self):
         self.login()
         self.module_test("openssl")
+        self.module_test("_openssl")
diff --git a/support/testing/tests/package/test_luasocket.py b/support/testing/tests/package/test_luasocket.py
index c2d19d78c..3d21df1de 100644
--- a/support/testing/tests/package/test_luasocket.py
+++ b/support/testing/tests/package/test_luasocket.py
@@ -10,6 +10,8 @@ class TestLuaLuaSocket(TestLuaBase):
 
     def test_run(self):
         self.login()
+        self.module_test("ltn12")
+        self.module_test("mime")
         self.module_test("socket")
 
 
@@ -22,4 +24,6 @@ class TestLuajitLuaSocket(TestLuaBase):
 
     def test_run(self):
         self.login()
+        self.module_test("ltn12")
+        self.module_test("mime")
         self.module_test("socket")
-- 
2.17.1

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

* [Buildroot] [PATCH 1/2] package/luarocks: better choice of modules in generated test
  2019-03-31  6:48 [Buildroot] [PATCH 1/2] package/luarocks: better choice of modules in generated test Francois Perrad
  2019-03-31  6:48 ` [Buildroot] [PATCH 2/2] support/testing/tests/package/test_lua*: regeneration Francois Perrad
@ 2019-03-31 10:15 ` Thomas Petazzoni
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2019-03-31 10:15 UTC (permalink / raw)
  To: buildroot

On Sun, 31 Mar 2019 08:48:44 +0200
Francois Perrad <fperrad@gmail.com> wrote:

> the name derived from package name is not suitable,
> so, we search in the built modules.
> 
> Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
> ---
>  package/luarocks/buildroot.lua | 31 +++++++++++++++++++++++++++----
>  1 file changed, 27 insertions(+), 4 deletions(-)

Both applied, thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

end of thread, other threads:[~2019-03-31 10:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-31  6:48 [Buildroot] [PATCH 1/2] package/luarocks: better choice of modules in generated test Francois Perrad
2019-03-31  6:48 ` [Buildroot] [PATCH 2/2] support/testing/tests/package/test_lua*: regeneration Francois Perrad
2019-03-31 10:15 ` [Buildroot] [PATCH 1/2] package/luarocks: better choice of modules in generated test Thomas Petazzoni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.