Author Topic: LuaTest - A Tool for Testing Scene Lua Code  (Read 19779 times)

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +476/-10
Re: LuaTest - A Tool for Testing Scene Lua Code
« Reply #15 on: May 05, 2014, 04:12:01 pm »
Quote
I'm doing some test but wanted to make you aware just in case there was something you could think of I could look for?

Your code is not ending. This could be an infinite loop or a socket call without a timeout that does not get a response. Default timeout for sockets is 0 (which means forever).

Offline akbooer

  • Master Member
  • *******
  • Posts: 4834
  • Karma: +207/-67
  • "Less is more"
Re: LuaTest - A Tool for Testing Scene Lua Code
« Reply #16 on: June 15, 2014, 09:11:51 am »
This is a brilliant addition to the Lua-user's toolbox.

I do seem to have run into trouble, though, and have narrowed it down to this one-liner example:
Code: [Select]
print (pretty {[table] = "a table index"})
...which causes a Luup restart (memory problem?)

I know that a circular structure will also break pretty, but this is not one of those.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P.
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay.

Offline Grwebster

  • Sr. Member
  • ****
  • Posts: 348
  • Karma: +3/-3
Re: LuaTest - A Tool for Testing Scene Lua Code
« Reply #17 on: June 28, 2014, 05:54:53 pm »
Sounds great and will certainly help debug. This is the kind of tool vera needs to provide to really jumpstart development.


Sent from my iPad using Tapatalk

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +476/-10
Re: LuaTest - A Tool for Testing Scene Lua Code
« Reply #18 on: July 29, 2014, 07:15:20 am »
Quote
This is a brilliant addition to the Lua-user's toolbox.

Thank you, sir. I appreciate your kind words.

Quote
I do seem to have run into trouble, though, and have narrowed it down to this one-liner example:

Code: [Select]
print (pretty {[table] = "a table index"})...which causes a Luup restart (memory problem?)

That's an interesting example. The variable table is of course an existing table that contains Lua's table manipulation functions. I would imagine that Lua is trying to tell you that you cannot use it as a table index but when LuaTest tries to dump the locals off the stack for the error diagnostics, it shoots itself in the foot again. On my system (LuaTest 1.5.2) it is reported as error in error handling but it does not crash Vera. I shall have to add some logic to catch recursive errors...

print (pretty {["table"] = "a table index"}) works just fine.

Quote
I know that a circular structure will also break pretty, but this is not one of those.

pretty attempts to spot circular structures (cycles) and avoid endless loops. It works fine on sockets which contain references to themselves.
« Last Edit: July 29, 2014, 07:18:17 am by RexBeckett »

Offline REMorrison

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
Re: LuaTest - A Tool for Testing Scene Lua Code - L_DataWatcher
« Reply #19 on: August 04, 2014, 01:54:25 pm »
I cannot find the file "L_DataWatcher" being required in the LUUP files list.  I have Vera2 with UI5 and wonder how many files are missing like this since average consumer doesn't plan to be developer.  I did upload the RBLuaTest.lua file and permanently install it.  A nudge in the right direct please?

Offline C4Vette

  • Full Member
  • ***
  • Posts: 157
  • Karma: +3/-8
Re: LuaTest - A Tool for Testing Scene Lua Code - L_DataWatcher
« Reply #20 on: August 04, 2014, 03:43:04 pm »
I cannot find the file "L_DataWatcher" being required in the LUUP files list.  I have Vera2 with UI5 and wonder how many files are missing like this since average consumer doesn't plan to be developer.  I did upload the RBLuaTest.lua file and permanently install it.  A nudge in the right direct please?
A nudge eh, well, I think you are asking in the wrong topic because I recognize that file as belonging to the plugin DataYours2. You can download the needed files for that plugin and upload them via the UI by choosing Apps, Develop Apps, Luup files.
But why did you put the require line there if you don't know what it is for?
« Last Edit: August 04, 2014, 03:47:22 pm by C4Vette »
VeraLite UI7 1.7.649
Fan of: PLEG, DataYours, dutchSmartMeter, MySensors

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +476/-10
LuaTest under UI7
« Reply #21 on: August 19, 2014, 08:49:51 pm »
LuaTest can be used on UI7. Almost everything works correctly. The only failure is that the Device Action List button does not work and produces a Handler failed message. I shall investigate...

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +476/-10
LuaTest 1.6 - A Tool for Testing Scene Lua Code
« Reply #22 on: August 20, 2014, 04:14:12 am »
LuaTest 1.6 uploaded. This fixes the problem of the Device Action List button not working under UI7. This version should work on UI5, UI6 or UI7.

See the first post for the code and instructions.

Offline hmspain

  • Hero Member
  • *****
  • Posts: 513
  • Karma: +16/-8
Re: LuaTest - A Tool for Testing Scene Lua Code
« Reply #23 on: August 25, 2014, 02:07:34 pm »
OK, I'm a noob, but this is amazing!  I agree with parkerc that it should be pinned, and i also think it should be make a permanent addition to Vera. (with a nice royalty paid to RexBeckett

I've been reading and playing and trying to code some things, but it's SO difficult to know what is going on (or what I'm doing wrong).  I've been able to accomplish things in other languages, but it helps to "see" my mistakes.  This tool allows that.  I spent most of yesterday trying things, and came back today to find a bunch of enhancements!

This is just to say THANK YOU to RexBeckett.

I just stumbled across LuaTest too, and I'm looking forward to trying it.  All weekend (well a good part of it), I've been trying to figure out why my luup code was not working.  A simple luup.log("Testing to see if I see ANYTHING!") results in nada.  luup.log(test_variable) outputs a "50" line to the log, but it was painful...

The "Test Luup code" window that Vera gives you should work like LuaTest; instead you press GO and cross your fingers :-).
« Last Edit: August 25, 2014, 02:09:32 pm by hmspain »
VeraPlus (1); Cameras (6), Sirens (2), Hue Bulbs/Strips/Blooms (42), Fan Dimmer (6), Aeon 4-in-1s (10), Water Sensors (3), Z-Wave Switches (20), Nest Smoke/CO Protects (5), Nest Thermostat Gen3 (1), HEM Gen2s (2)

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +476/-10
Re: LuaTest - A Tool for Testing Scene Lua Code
« Reply #24 on: August 25, 2014, 05:38:25 pm »
Quote
instead you press GO and cross your fingers :-).

That's why I created LuaTest. It's hard to write good code with your fingers crossed.  ;D

Offline marcbea

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: LuaTest - A Tool for Testing Scene Lua Code
« Reply #25 on: October 14, 2014, 06:18:23 pm »
I'm trying to run this but all i get is no handler from the url. Am i doing something wrong? I've followed all the instructions and restarted my vera. Run the code from the test luup code box but still unable to get it to load.

I'm running UI7 FW1.7.388

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +476/-10
Re: LuaTest - A Tool for Testing Scene Lua Code
« Reply #26 on: October 17, 2014, 08:51:50 am »
I'm trying to run this but all i get is no handler from the url. Am i doing something wrong? I've followed all the instructions and restarted my vera. Run the code from the test luup code box but still unable to get it to load.

I'm running UI7 FW1.7.388

Do you get any error message when you run the three lines in Test Luup? It is possible that Vera is restarting after you run this code - UI7 can do that sometimes. This would lose the link to the handler. If the three lines run without error, you could place them at the end of Startup Lua so that the handler is permanently registered.

Offline sgs

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
Re: LuaTest - A Tool for Testing Scene Lua Code
« Reply #27 on: October 24, 2014, 10:15:54 pm »
Another fan of this tool here.  Up and going in minutes.
What a great way to test the logic of code you want to add to scenes, etc.

Many thanks.

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +476/-10
Re: LuaTest - A Tool for Testing Scene Lua Code
« Reply #28 on: October 25, 2014, 05:28:47 am »
Another fan of this tool here.  Up and going in minutes.
What a great way to test the logic of code you want to add to scenes, etc.

Many thanks.

Thanks for the feedback, @sgs. I'm glad you are finding it useful.

Offline Peter

  • Jr. Member
  • **
  • Posts: 95
  • Karma: +0/-0
Re: LuaTest - A Tool for Testing Scene Lua Code
« Reply #29 on: October 25, 2014, 05:52:25 am »
What a great tool this is Rex.
Try for a while things in lua but I never got very far. This really helps me big steps forward.

The only thing missing is to add automatic or context help on the function you are using. But I know this is asking too much.

But I'd already be very happy, with a lua help for beginners.
Or links to good help sites, with good examples as part of this tool.