Add unit tests for lua backends
ClosedPublic

Authored by sirgienko on Mar 29 2018, 8:33 PM.

Details

Summary

According T3872, I have added some simple unit tests for lua backend, checking results with lua. The tests coverage some most common use. But not all tests pass completely: some tests skipped because of problems with the lua backend.

Test Plan
  1. run testlua

Diff Detail

Repository
R55 Cantor
Branch
add-lua-unit-tests
Lint
No Linters Available
Unit
No Unit Test Coverage
sirgienko created this revision.Mar 29 2018, 8:33 PM
Restricted Application added a project: KDE Edu. · View Herald TranscriptMar 29 2018, 8:33 PM
Restricted Application added a subscriber: KDE Edu. · View Herald Transcript
sirgienko requested review of this revision.Mar 29 2018, 8:33 PM

Just a example of appearens input in output (i don't want add image in patch summary).

Just a example of appearens input in output (i don't want add image in patch summary).

@filipesaraiva I have some troubles to compile&link the lua backend at the moment. Can you please help to validate this?

asemke added a comment.Apr 8 2018, 3:54 PM

Just a example of appearens input in output (i don't want add image in patch summary).

Lua's output for Cantor's input

"s=3;\nprint(s)"

is

"s=3;\n print(s)\n3"

I'm not sure how to fix this, this looks like a limitation of the interpreter. Let's disable/remove the tests failing because of this specific problem and add all the other tests which work. Having couple of tests is better than having no tests.

Just a example of appearens input in output (i don't want add image in patch summary).

Lua's output for Cantor's input

"s=3;\nprint(s)"

is

"s=3;\n print(s)\n3"

I'm not sure how to fix this, this looks like a limitation of the interpreter. Let's disable/remove the tests failing because of this specific problem and add all the other tests which work. Having couple of tests is better than having no tests.

Well, I will do it, but first i want to spend some time for attempts to fix this problem, maybe i will find cause of this.

sirgienko added a comment.EditedApr 9 2018, 6:52 PM

@asemke, I have tested this tests with D12074 and and everything seems to work, but with problems: for the some reason sometimes we start checking, before evualation have result (and even before evualation take output from lua interpreter). I think, I will investigate this situation and will try to achieve 100 percent passage of tests

Well, maybe I found the problem of unstable tests result: repeating lua input in output and not numbered line produce situation, that sometimes we end output parsing, because aviable lua output ends, but lua VM doesn't end work. For example, if we run

print(3)
print(4)

We could end parsing after getting result of first command (if we read lua prompt before lua repeats the command to output, for this example, read > before print(4) will be writed in output chanell (there is delay between this moments)) and set status Done, but output don't end and we have result of second command in output.
I think, It's not a problem for Cantor GUI, because I haven't notice this problem, while I have worked with the worksheet, but it affects to test results.
I think, there are few ways to work with it:

  1. Change expresssion end condition: we know, that lua repeat all input to output, so we could wait, until read all input commands in output
  2. Just ignore this problem and run tests few times and take maximum of passed tests

With D12074 last update all tests now pass with 100% (sometimes problem with lua prompt parsing (fail one test), but it is problem of login mechanism).
So, @asemke, could you test this tests with D12074?

testIfElseCondition() and testForLoop() fail...

sirgienko updated this revision to Diff 33175.Apr 26 2018, 9:34 PM

Add skipping for tests, which not working because of problems unrelated to the tests.

Possible fail of the first test, because of problems with reading intro message. This is backend's problem, so I'll deal with this in another patch.

asemke accepted this revision.Apr 27 2018, 3:23 PM
This revision is now accepted and ready to land.Apr 27 2018, 3:23 PM
sirgienko edited the summary of this revision. (Show Details)Apr 27 2018, 5:49 PM
sirgienko closed this revision.Apr 27 2018, 5:51 PM