Skip to content

terminaldweller/luactest

Repository files navigation

Build Status Total alerts FOSSA Status Coverity Scan Build Status

luactest

The idea is to be able to write and run tests for C functions in Lua. inspired by me being lazy and my life being too short for writing tests for C in C.
The workflow is the clang libtooling tool under libtool will find the funcitons and add their lua wrapper into source code and register it with lua. luatablegen is a python script that takes an XML script describing your C structs and turns them into lua tables since almost every non-toy C code uses structs anyways and adding C structs as Lua tables is non-trivial. after that you just build the tool(its not a typo, you actually build your tool) which is a Lua 5.3 interpreter. you then write your test scripts in Lua and run them. linenoise is there to give you some basic cli functionality if you choose to run the tool in interactive mode. the default.lua file works as the dot file. The default provided will add your luarocks libraries to our custom Lua instance for some added quality of life.

Demo

you can run the makefile in the root directory. then run the executable, type in dofile("./test.lua")and see the result. it runs our little test function from Lua which converts a string into an integer. <br>

TODO

  • write the libtooling tool.
  • need to add completion and hints for linenoise.
  • add non-interactive execution to tool.
  • add cygwin support because i have to use windows at work...

Notes

The luarocks feature work for Lua 5.3. I haven't looked at the Lua 5.4 changelog yet.

Build

If you don't have clang, subtitute all make commands with make CC=gcc.
Then run:

git clone https://github.com/bloodstalker/luactest
git submodule init
git submodule update
make

To build the libtooling tool run make under libtool directory.
The tool right now should support LLVM 5,6,8 and 9(latest tested trunk:355787).

License

FOSSA Status

About

Run tests for your C functions from Lua semi-automatically.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published