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 (58 lines) | stat: -rw-r--r-- 1,962 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
includecommon("automate_stdio.lua")

mtn_setup()

addfile("testfile", "foo bar")
check(mtn("ci", "-m", "foobar"), 0, false, false)

-- Run some commands outside a workspace so they don't get the db from
-- the workspace options.
outside_ws_dir = make_temp_dir()

check(indir(outside_ws_dir, nodb_mtn("genkey", "foo@bar.com")),
      0, false, false, string.rep("foo@bar.com\n", 2))

check(mtn("genkey", "foo@baz.com"),
      0, false, false, string.rep("foo@baz.com\n", 2))

check(indir(outside_ws_dir, nodb_mtn("dropkey", "foo@baz.com")), 0, false, false)

-- we now have foo@bar.com in the keystore, tester@test.net in both keystore
-- and database, and foo@baz.com in only the database
function check_keys(dat)
  parsed = parse_basic_io(dat)
  locs = {}
  for _,line in pairs(parsed) do
    if line.name == "given_name" then
      key = line.values[1]
      locs[key] = {db = false, ks = false, pub = false, priv = false}
    end
    if string.find(line.name, "location") then
      for _,v in pairs(line.values) do
        if v == "keystore" then locs[key].ks = true end
        if v == "database" then locs[key].db = true end
      end
    end
    if string.find(line.name, "private") then locs[key].priv = true end
    if string.find(line.name, "public") then locs[key].pub = true end
  end
  check(locs["foo@bar.com"].db == false)
  check(locs["foo@bar.com"].ks == true)
  check(locs["foo@baz.com"].priv == false)
  check(locs["foo@baz.com"].pub == true)
  check(locs["tester@test.net"].db == true)
  check(locs["tester@test.net"].ks == true)
  check(locs["tester@test.net"].pub == true)
  check(locs["tester@test.net"].priv == true)
end

check(mtn("automate", "keys"), 0, true, false)
check_keys(readfile("stdout"))

-- Ensure that 'keys' gets the keydir from workspace options even when
-- run via stdio
check(mtn_ws_opts("automate", "stdio"), 0, true, false, "l4:keyse")
local keys = parse_stdio(readfile("stdout"), 0)
check_keys(keys)

-- end of file