Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Nov 20, 2020. It is now read-only.
forked from lunarmodules/Penlight
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.lua
More file actions
Latest commit
66 lines (55 loc) · 1.58 KB
/
Copy pathrun.lua
File metadata and controls
66 lines (55 loc) · 1.58 KB
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
-- Running tests and/or examples.
locallfs=require"lfs"
localdirectories= {}
localluacov=false
for_, argumentinipairs(arg) do
ifargument=="--help" then
print("Usage: lua run.lua [--luacov] [<dir>]...")
os.exit(0)
elseifargument=="--luacov" then
luacov=true
else
table.insert(directories, argument)
end
end
if#directories==0then
directories= {"tests", "examples"}
end
locallua="lua"
locali=-1
whilearg[i] do
lua=arg[i]
i=i-1
end
ifluacovthen
lua=lua.." -lluacov"
end
localdir_sep=package.config:sub(1, 1)
localquote=dir_sep=="/" and"'" or'"'
localpl_src="lua" ..dir_sep.."?.lua"
lua=lua.." -e " ..quote.."package.path=[[" ..pl_src..";]]..package.path" ..quote
localfunctionrun_directory(dir)
localfiles= {}
forpathinlfs.dir(dir) do
localfull_path=dir..dir_sep..path
ifpath:find("%.lua$") andlfs.attributes(full_path, "mode") =="file" then
table.insert(files, full_path)
end
end
table.sort(files)
for_, fileinipairs(files) do
localcmd=lua.."" ..file
print("Running " ..file)
localcode1, _, code2=os.execute(cmd)
localcode=type(code1) =="number" andcode1orcode2
ifcode~=0then
print(("Running %s failed with code %d"):format(file, code))
os.exit(1)
end
end
end
for_, dirinipairs(directories) do
print("Running files in " ..dir)
run_directory(dir)
end
print("Run completed successfully")