summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/luatex/lualibs/test-lualibs.lua
blob: afc674db6897a4d96d384a2b7cfb2609569f3443 (plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env texlua

local luafiles = {
  "lualibs-boolean.lua",   "lualibs-compat.lua",
  "lualibs-dir.lua",       "lualibs-file.lua",
  "lualibs-gzip.lua",
  "lualibs-function.lua",  "lualibs-io.lua",
  "lualibs-lpeg.lua",      "lualibs-lua.lua",
  "lualibs-math.lua",      "lualibs-md5.lua",
  "lualibs-number.lua",    "lualibs-os.lua",
  "lualibs-package.lua",   "lualibs-set.lua",
  "lualibs-string.lua",    "lualibs-table.lua",
  "lualibs-trac-inf.lua",  "lualibs-unicode.lua",
  "lualibs-url.lua",       "lualibs-util-deb.lua",
  "lualibs-util-dim.lua",
  "lualibs-util-jsn.lua",  "lualibs-util-lua.lua",
  "lualibs-util-prs.lua",  "lualibs-util-sta.lua",
  "lualibs-util-sto.lua",  "lualibs-util-str.lua",
  "lualibs-util-tab.lua",
  "lualibs-util-tpl.lua",  "lualibs.lua",
  "lualibs-basic.lua",     "lualibs-basic-merged.lua",
  "lualibs-extended.lua",  "lualibs-extended-merged.lua",
}

local test_cmd = "texluac -p %s &> /dev/null"

local check_wellformed = function (file)
  io.write"testing "
  io.write(file)
  io.write" ... "
  local exit_status = os.execute(string.format(test_cmd, file))
  if exit_status == 0 then
    io.write"SUCCESS!\n"
    return true
  end
  io.write"FAIL :-/\n"
  return false
end

local check_files check_files = function (lst, n)
  if n == nil then
    return check_files(lst, 1)
  end
  local this = lst[n]
  if this then
    if check_wellformed(this) then
      return check_files(lst, n+1)
    else
      return false
    end
  end
  return true
end

config = { lualibs = { force_reload = true } }

local load_all = function ( )

  io.write"testing merged packages ... "
  config.lualibs.prefer_merged = true
  if not pcall(function () dofile"lualibs.lua"end) then
    io.write"FAIL :-/\n"
  end
  io.write"SUCCESS\n"

  io.write"testing files ... "
  config.lualibs.prefer_merged = false
  if not pcall(function () dofile"lualibs.lua"end) then
    io.write"FAIL :-/\n"
  end
  io.write"SUCCESS\n"
  return true
end

local main = function ( )
  local retval = 0
  retval = check_files(luafiles) and retval or 1
  retval = load_all()            and retval or 1
  os.exit(retval)
end

return main()