File: __driver__.lua

package info (click to toggle)
monotone 1.1-9
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 20,984 kB
  • ctags: 8,622
  • sloc: cpp: 86,450; sh: 6,906; perl: 924; makefile: 813; python: 517; lisp: 379; sql: 118; exp: 91; ansic: 52
file content (33 lines) | stat: -rw-r--r-- 859 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

mtn_setup()

check(mtn("au", "get_file_size", string.rep("0123", 10)), 1, false, true)
check(qgrep("no file version " .. string.rep("0123", 10) .. " found in database", "stderr"))

addfile("foo", "")
commit()

local files = { "random1", "random2", "random3" }
local data = {}

-- build the data forward
for _,v in pairs(files) do
    get(v)
    contents = readfile(v)
    expected = string.len(contents)
    check(mtn("au", "identify", v), 0, true, false)
    ident = string.sub(readfile("stdout"), 1, -2)

    writefile("foo", contents)
    commit()

    data[v] = { ["expected"]=expected, ["ident"]=ident }
end

-- ...and check them in reverse
for idx = #files, 1, -1 do
    check(mtn("au", "get_file_size", data[files[idx]].ident), 0, true, false)
    got = string.sub(readfile("stdout"), 1, -2)
    check(data[files[idx]].expected == tonumber(got))
end