diff mbox series

[RFC,2/4] support/testing: add perl-time-hires test

Message ID 20181117175244.23594-3-francois.perrad@gadz.org
State Superseded
Headers show
Series suppport/testing: Perl, Lua and their modules | expand

Commit Message

Francois Perrad Nov. 17, 2018, 5:52 p.m. UTC
Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
---
 .gitlab-ci.yml                                       |  1 +
 .../testing/tests/package/test_perl_time_hires.py    | 12 ++++++++++++
 2 files changed, 13 insertions(+)
 create mode 100644 support/testing/tests/package/test_perl_time_hires.py

Comments

Ricardo Martincoski Nov. 19, 2018, 1:14 a.m. UTC | #1
Hello,

Just giving an example of what I mentioned in a reply to the cover letter...

On Sat, Nov 17, 2018 at 03:52 PM, Francois Perrad wrote:

[snip]
> +class TestPerlTimeHiRes(TestPerl):
> +    config = TestPerl.config + \
> +        """
> +        BR2_PACKAGE_PERL_TIME_HIRES=y
> +        """
> +
> +    def test_run(self):
> +        self.login()
> +        self.module_test("Time::HiRes")

Another way to test a perl package would be to have an script added to the image
in build time, something like this:
sample_perl_time_hires.pl:
|use Time::HiRes;
|
|Time::HiRes::usleep(1_000_000)

And call:
perl sample_perl_time_hires.pl

This way we could test scripts with a few lines of code and keep it readable in
the tree.


Regards,
Ricardo
Francois Perrad Nov. 19, 2018, 7:29 p.m. UTC | #2
Le lun. 19 nov. 2018 à 02:14, Ricardo Martincoski <
ricardo.martincoski@gmail.com> a écrit :

> Hello,
>
> Just giving an example of what I mentioned in a reply to the cover
> letter...
>
> On Sat, Nov 17, 2018 at 03:52 PM, Francois Perrad wrote:
>
> [snip]
> > +class TestPerlTimeHiRes(TestPerl):
> > +    config = TestPerl.config + \
> > +        """
> > +        BR2_PACKAGE_PERL_TIME_HIRES=y
> > +        """
> > +
> > +    def test_run(self):
> > +        self.login()
> > +        self.module_test("Time::HiRes")
>
> Another way to test a perl package would be to have an script added to the
> image
> in build time, something like this:
> sample_perl_time_hires.pl:
> |use Time::HiRes;
> |
> |Time::HiRes::usleep(1_000_000)
>
> And call:
> perl sample_perl_time_hires.pl
>
> This way we could test scripts with a few lines of code and keep it
> readable in
> the tree.
>
>
With the current TestPerl class, this test could be written as:
        self.module_test("Time::HiRes", "Time::HiRes::usleep(1_000_000);")
A long oneliner script could be written with a multiline layout, like this:
        self.module_test("Time::HiRes", "use strict;" +
                                        "use warnings;" +
                                        "Time::HiRes::usleep(1_000_000);")
So, we don't need to handle sample_perl_*.pl scripts.
Same thing with Lua.

François


>
> Regards,
> Ricardo
<div dir="ltr"><div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">Le lun. 19 nov. 2018 à 02:14, Ricardo Martincoski &lt;<a href="mailto:ricardo.martincoski@gmail.com">ricardo.martincoski@gmail.com</a>&gt; a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
<br>
Just giving an example of what I mentioned in a reply to the cover letter...<br>
<br>
On Sat, Nov 17, 2018 at 03:52 PM, Francois Perrad wrote:<br>
<br>
[snip]<br>
&gt; +class TestPerlTimeHiRes(TestPerl):<br>
&gt; +    config = TestPerl.config + \<br>
&gt; +        &quot;&quot;&quot;<br>
&gt; +        BR2_PACKAGE_PERL_TIME_HIRES=y<br>
&gt; +        &quot;&quot;&quot;<br>
&gt; +<br>
&gt; +    def test_run(self):<br>
&gt; +        self.login()<br>
&gt; +        self.module_test(&quot;Time::HiRes&quot;)<br>
<br>
Another way to test a perl package would be to have an script added to the image<br>
in build time, something like this:<br>
<a href="http://sample_perl_time_hires.pl" rel="noreferrer" target="_blank">sample_perl_time_hires.pl</a>:<br>
|use Time::HiRes;<br>
|<br>
|Time::HiRes::usleep(1_000_000)<br>
<br>
And call:<br>
perl <a href="http://sample_perl_time_hires.pl" rel="noreferrer" target="_blank">sample_perl_time_hires.pl</a><br>
<br>
This way we could test scripts with a few lines of code and keep it readable in<br>
the tree.<br>
<br></blockquote><div><br></div><div>With the current TestPerl class, this test could be written as:<br>        self.module_test(&quot;Time::HiRes&quot;, &quot;Time::HiRes::usleep(1_000_000);&quot;)<br>A long oneliner script could be written with a multiline layout, like this:<br>        self.module_test(&quot;Time::HiRes&quot;, &quot;use strict;&quot; +<br>                                        &quot;use warnings;&quot; +<br>                                        &quot;Time::HiRes::usleep(1_000_000);&quot;)<br>So, we don&#39;t need to handle sample_perl_*.pl scripts.<br>Same thing with Lua.</div><div><br></div><div>François<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Regards,<br>
Ricardo</blockquote></div></div></div>
Ricardo Martincoski Nov. 19, 2018, 10:57 p.m. UTC | #3
Hello,

On Mon, Nov 19, 2018 at 05:29 PM, François Perrad wrote:

> Le lun. 19 nov. 2018 à 02:14, Ricardo Martincoski <
> ricardo.martincoski@gmail.com> a écrit :
[snip]
>> Another way to test a perl package would be to have an script added to the
>> image
>> in build time, something like this:
>> sample_perl_time_hires.pl:
>> |use Time::HiRes;
>> |
>> |Time::HiRes::usleep(1_000_000)
>>
>> And call:
>> perl sample_perl_time_hires.pl
>>
>> This way we could test scripts with a few lines of code and keep it
>> readable in
>> the tree.
>>
>>
> With the current TestPerl class, this test could be written as:
>         self.module_test("Time::HiRes", "Time::HiRes::usleep(1_000_000);")
> A long oneliner script could be written with a multiline layout, like this:
>         self.module_test("Time::HiRes", "use strict;" +
>                                         "use warnings;" +
>                                         "Time::HiRes::usleep(1_000_000);")
> So, we don't need to handle sample_perl_*.pl scripts.
> Same thing with Lua.

This is (kind of) how we were handling the tests for python packages before.

But you have a point.

Testing python packages got really messy when a class was needed in the script
because of the indentation. In those cases a oneliner was not enough.
Lua and Perl packages can always be tested with oneliners AFAIK.

Another issue that made python scripts less readable was the escaping for string
delimiters.
I guess that for lua and perl scripts we can always use those fancy quotes
([[string]], q{string}) when needed.

If Thomas and Arnout don't disagree, let's keep using oneliners to test lua and
perl packages, as you originally proposed.


Regards,
Ricardo
diff mbox series

Patch

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ae5d57026..b3d5616f1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -313,6 +313,7 @@  tests.package.test_dropbear.TestDropbear: *runtime_test
 tests.package.test_ipython.TestIPythonPy2: *runtime_test
 tests.package.test_ipython.TestIPythonPy3: *runtime_test
 tests.package.test_perl.TestPerl: *runtime_test
+tests.package.test_perl_time_hires.TestPerlTimeHiRes: *runtime_test
 tests.package.test_python.TestPython2: *runtime_test
 tests.package.test_python.TestPython3: *runtime_test
 tests.package.test_python_autobahn.TestPythonPy2Autobahn: *runtime_test
diff --git a/support/testing/tests/package/test_perl_time_hires.py b/support/testing/tests/package/test_perl_time_hires.py
new file mode 100644
index 000000000..2f7e1d119
--- /dev/null
+++ b/support/testing/tests/package/test_perl_time_hires.py
@@ -0,0 +1,12 @@ 
+from tests.package.test_perl import TestPerl
+
+
+class TestPerlTimeHiRes(TestPerl):
+    config = TestPerl.config + \
+        """
+        BR2_PACKAGE_PERL_TIME_HIRES=y
+        """
+
+    def test_run(self):
+        self.login()
+        self.module_test("Time::HiRes")