www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - bluejay - integration/application test runner

Bluejay is an application test runner, allowing easy writing of cross-
platform tests.

Bluejay uses Lua (via LuaD) with a small test library and is on the dub 
registry at http://code.dlang.org/packages/bluejay

I also converted the first 37 test cases of DCD[1] to try it out - so 
those tests can now be run on Windows (note that the original scripts only 
restart dcd-server when it crashes; my tests start and stop it for each 
test case so it's much slower).

A couple of examples:

```
 #!/usr/bin/env bluejay

local ret = Test:run("echo", "asdf")

-- We don't care about the whitespace, which is system-dependent.
assert(Util:strip(ret.Output) == "asdf")
assert(ret.ReturnCode == 0)

-- Or if we do care, we can also make the assertion based on the host
-- operating system.
if (System.OS == "Windows") then
    assert(ret.Output == "asdf\r\n")
else
    assert(ret.Output == "asdf\n")
end
```

```
#!/usr/bin/env bluejay

-- The cleanup function, if defined, will run regardless of test success,
-- failure, or error.
function cleanup()
    print('Cleanup tasks go here.')
end

dofile('mytestfunctions.lua')
doTestSetup() -- Assuming this is in mytestfunctions.lua

local tests = {'arg1', 'arg2', 'arg3'}
local returns = {'out1', 'out2', 'out3'}

for i, t in ipairs(tests) do
    local ret = Test:run('myapplication', '--someflag ' .. t)
    assert(ret.Output == returns[i], 'Test number ' .. i .. ' failed.')
end
```

[1]: https://github.com/rjframe/DCD
Aug 11