Skip to content

Commit

Permalink
Fix scripts for testing to use a given build directory
Browse files Browse the repository at this point in the history
  • Loading branch information
franko committed May 21, 2020
1 parent fd23e59 commit 01d1604
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
47 changes: 47 additions & 0 deletions developer-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Developer's Notes for LuaJIT Language Toolkit

## Build Instructions

The standard method to build the luajit language toolkit is to use the Meson build system.

Here an example of using meson:

```sh
meson setup build # configure the build
ninja -C build # build
```

Of course Meson and Ninja are required. In alternative Meson can use GNU Make as a backend but using Ninja is recommended.

In addition to Meson a working luajit installed in your path is also needed.

At your convenience you may install LuaJIT using the [Little Library Helper](https://github.com/franko/lhelper).
Its usage is to create an build environment and to install luajit:

```bash
lhelper create luajit-env # create a new environment
lhelper activate luajit-env # activate the environment
lhelper install luajit # install luajit executable and library
```

The environment will remains and can be later reused using again the 'lhelper activate' command.

On Linux or other unix-like environment Lhelper can be used or you may install luajit using the standard package manager.

## Running the tests

The language toolkit has a large corpus of tests. They can be ran in different modes but it always involves running the standard luajit executable and compare the output with the language toolkit.

The output can be compared in the following ways:

1. compare directly the output of the Lua test program
2. compare the listing of the bytecode instructions
3. compare the hexadecimal dump of the bytecode, byte-per-byte

To run the tests the following commands should be used respectively, depending on the mode:

1. `python2 scripts/test-output.by <build-directory>`
2. `python2 scripts/test-bytecode.by <build-directory>`
3. `python2 scripts/test-bytecode-hex.by <build-directory>`

For each command the directory tests/log will be populated with some logs to compare the differences in the output and the listing of the generated bytecode.
8 changes: 7 additions & 1 deletion scripts/test-bytecode-hex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
import StringIO
from glob import glob

if len(sys.argv) != 2:
print("usage: %s <build-directory>" % sys.argv[0])
sys.exit(1)

build_dir = sys.argv[1]

test_dir = "tests"
luajit_exec = "luajit"
luajit_x = "./src/luajit-x"
luajit_x = os.path.join(build_dir, "src/luajit-x")
diff_exec = "diff"

def lua_files(test_dir):
Expand Down
8 changes: 7 additions & 1 deletion scripts/test-bytecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
import StringIO
from glob import glob

if len(sys.argv) != 2:
print("usage: %s <build-directory>" % sys.argv[0])
sys.exit(1)

build_dir = sys.argv[1]

test_dir = "tests"
luajit_exec = "luajit"
luajit_x = "./src/luajit-x"
luajit_x = os.path.join(build_dir, "src/luajit-x")
diff_exec = "diff"

def lua_files(test_dir):
Expand Down
8 changes: 7 additions & 1 deletion scripts/test-output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
import re
import subprocess

if len(sys.argv) != 2:
print("usage: %s <build-directory>" % sys.argv[0])
sys.exit(1)

build_dir = sys.argv[1]

test_dir = "tests"
luajit_exec = "luajit"
luajit_x = "./src/luajit-x"
luajit_x = os.path.join(build_dir, "src/luajit-x")

if not os.path.isdir("tests/log"):
try:
Expand Down

0 comments on commit 01d1604

Please sign in to comment.