monotone

monotone Mtn Source Tree

Root/unit-testsuite.lua

1-- This test suite is special; it synthesizes all its __driver__.lua
2-- files on the fly. Each one runs the 'unit_tests' binary over just
3-- one of the test cases it can run.
4
5testdir = initial_dir .. "/unit-tests"
6
7function prepare_to_enumerate_tests (P)
8 local unit_test_path = getpathof("unit_tester")
9 if unit_test_path == nil then return 1 end
10
11 writefile_q("in", nil)
12 prepare_redirect("in", "out", "err")
13 local status = execute(unit_test_path)
14 local out = readfile_q("out")
15 local err = readfile_q("err")
16
17 if status == 0 and err == "" and out ~= "" then
18 unlogged_remove(testdir)
19 unlogged_mkdir(testdir)
20 for tcase in string.gmatch(out, "[%w_:]+") do
21 local tdir = string.gsub(tcase, ':', '_')
22 unlogged_mkdir(testdir .. "/" .. tdir)
23 writefile_q(testdir .. "/" .. tdir .. "/__driver__.lua",
24 string.format("check({ %q, %q }, 0, true, true)\n",
25 unit_test_path, tcase))
26 end
27 else
28 P(string.format("%s: exit %d\nstdout:\n", unit_test_path, status))
29 P(out)
30 P("stderr:\n")
31 P(err)
32
33 if status == 0 then status = 1 end
34 end
35
36 unlogged_remove("in")
37 unlogged_remove("out")
38 unlogged_remove("err")
39 return status
40end
41
42-- Cloned from testsuite.lua; just dumps information about the monotone
43-- build into the master logfile.
44
45function prepare_to_run_tests (P)
46 local monotone_path = getpathof("mtn")
47 if monotone_path == nil then monotone_path = "mtn" end
48
49 writefile_q("in", nil)
50 prepare_redirect("in", "out", "err")
51
52 local status = execute(monotone_path, "version", "--full")
53 local out = readfile_q("out")
54 local err = readfile_q("err")
55
56 if status == 0 and err == "" and out ~= "" then
57 logfile:write(out)
58 else
59 P(string.format("mtn version --full: exit %d\nstdout:\n", status))
60 P(out)
61 P("stderr:\n")
62 P(err)
63
64 if status == 0 then status = 1 end
65 end
66
67 unlogged_remove("in")
68 unlogged_remove("out")
69 unlogged_remove("err")
70 return status
71end

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status