Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

LDT/Developer Area/Testing ASTs

< LDT
Revision as of 09:03, 4 June 2012 by Unnamed Poltroon (Talk) (Dependencies)

In Koneki LDT, we deal with Lua code. Our tool have to analyze code provided by users. In order to do so, we generate ASTs which are data structures representing code. When we change generation process, several problems occur:

  • Are the changes effective?
  • Do they cause regressions?
  • Do they affect performances?

In order to detect failure, we will run Unit test as AST generation smoke tests.

Create AST tests

Before performing any work on ASTs we might create some.

Create a reference AST

The idea is to load a Lua source file as plain text. Process it like we do for regular source files. The result of this operation is a plain Lua table described parsed source. Now we will serialize this table using Metalua and store it in a file. The content of this file is not going to change, we will use it as reference.

Valid new AST generation

When AST generation will be changed, we will compare newly generated ASTs with reference one. New ASTs will be generated from the same source as the reference one. Then if new and old ASTs are equivalent, AST generation is successful. It is all automatic and convenient to test large files as it is not necessary to describe them manually.

Dependencies

No worries, all testing requirements are already part of our target platform. Serialization will be performed with Metalua, unserialization is done with loadstring, which is a built in Lua function. Unit test framework will be JUnit. AST generation and table comparison will be done using Lua.

Aternatives

While loading strings from Metalua serailization we had some weird behaviors. If it does not meet our expectations we might try Data Dumper, which has similar features.

Back to the top