-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlakefile.lean
More file actions
211 lines (184 loc) · 6 KB
/
Copy pathlakefile.lean
File metadata and controls
211 lines (184 loc) · 6 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
import Lake
open Lake DSL
package "protobuf" where
version := v!"0.4.0"
releaseRepo := "https://github.com/Lean-zh/protobuf"
preferReleaseBuild := true
require binary from git "https://github.com/Lean-zh/binary.git"
@[default_target]
lean_lib Protobuf where
-- The `Protobuf` root does not import `Protobuf.Json`, so name it here as
-- well; the release archive ships exactly what this library builds.
globs := #[.one `Protobuf, .one `Protobuf.Json]
lean_exe Plugin where
root := `Plugin
exeName := "protoc-gen-lean4"
lean_lib Bench where
roots := #[`Test.Bench]
lean_exe benchWire where
root := `Test.Bench.Wire
lean_exe benchCodec where
root := `Test.Bench.Codec
lean_exe testVersionsSemantics where
root := `Test.Runtime.VersionsSemantics
lean_exe testVersionsValidation where
root := `Test.Core.VersionsValidation
lean_exe testExtensions where
root := `Test.Runtime.Extensions
lean_exe testClosedEnum where
root := `Test.Runtime.ClosedEnum
lean_exe testUtf8Validation where
root := `Test.Runtime.Utf8Validation
lean_exe testReflection where
root := `Test.Runtime.Reflection
lean_exe testProtoJson where
root := `Test.Runtime.ProtoJson
lean_exe testProtoJsonWellKnown where
root := `Test.Runtime.ProtoJsonWellKnown
lean_exe testProtoJsonConformance where
root := `Test.Conformance.ProtoJsonConformance
lean_lib Tests where
roots := #[
`Test.Core.Utils,
`Test.Core.EncodingWire,
`Test.Core.Desc,
`Test.Core.VersionsValidation,
`Test.Codegen.ExtensionTagBase,
`Test.Codegen.ExtensionKnownTagCollisionsBase,
`Test.Codegen.ExtensionKnownTagCollisions,
`Test.Codegen.NotationSyntax,
`Test.Codegen.Folder,
`Test.Codegen.NamingCollisions,
`Test.Codegen.WideCodegen,
`Test.Codegen.OneofParentCollisionBase,
`Test.Codegen.OneofParentCollisions,
`Test.Codegen.RootName,
`Test.Codegen.VisibilityRetainedOptions,
`Test.Runtime.Proto3,
`Test.Runtime.VersionsSemantics,
`Test.Runtime.Extensions,
`Test.Runtime.ClosedEnum,
`Test.Runtime.Utf8Validation,
`Test.Runtime.Reflection,
`Test.Runtime.ProtoJson,
`Test.Runtime.ProtoJsonWellKnown,
`Test.Runtime.RecursionDepth,
`Test.Runtime.RequiredMerge,
`Test.Runtime.Groups,
`Test.Integration.ElabStandaloneImport,
`Test.Official.OfficialSmokeUnittestProto3,
`Test.Official.OfficialStruct,
`Test.Official.OfficialConformanceProto3
]
@[test_driver]
script test (_args) do
let runLake (args : Array String) : IO UInt32 := do
let child ← IO.Process.spawn {
cmd := "lake"
args
stdin := .inherit
stdout := .inherit
stderr := .inherit
}
child.wait
let buildExit ← runLake #[
"build",
"+Test.Core.Utils",
"+Test.Core.EncodingWire",
"+Test.Codegen.ExtensionTagBase",
"+Test.Codegen.ExtensionKnownTagCollisions",
"+Test.Codegen.NotationSyntax",
"+Test.Codegen.Folder",
"+Test.Core.Desc",
"+Test.Runtime.Proto3",
"+Test.Runtime.RecursionDepth",
"+Test.Runtime.RequiredMerge",
"+Test.Runtime.Groups",
"+Test.Codegen.NamingCollisions",
"+Test.Codegen.WideCodegen",
"+Test.Codegen.OneofParentCollisions",
"+Test.Codegen.RootName",
"+Test.Integration.ElabStandaloneImport",
"+Test.Codegen.VisibilityRetainedOptions",
"+Test.Official.OfficialSmokeUnittestProto3",
"+Test.Official.OfficialStruct",
"Plugin",
"testVersionsSemantics",
"testVersionsValidation",
"testExtensions",
"testClosedEnum",
"testUtf8Validation",
"testReflection",
"testProtoJson",
"testProtoJsonWellKnown"
]
if buildExit != 0 then
return buildExit
-- Keep the largest upstream schema in a separate Lake invocation so it
-- cannot overlap other generated-code jobs and multiply peak memory usage.
let conformanceExit ←
runLake #["build", "+Test.Official.OfficialConformanceProto3"]
if conformanceExit != 0 then
return conformanceExit
for executable in #[
"testVersionsSemantics",
"testVersionsValidation",
"testExtensions",
"testClosedEnum",
"testUtf8Validation",
"testReflection",
"testProtoJson",
"testProtoJsonWellKnown"
] do
let runExit ← runLake #["exe", executable]
if runExit != 0 then
return runExit
let pluginTest ← IO.Process.spawn {
cmd := "bash"
args := #["Test/Integration/Plugin.sh"]
stdin := .inherit
stdout := .inherit
stderr := .inherit
}
let pluginExit ← pluginTest.wait
if pluginExit != 0 then
return pluginExit
-- Nothing below the `Protobuf` root imports `Protobuf.Json`, so only the
-- library's globs keep it in the build, and a release archive holds exactly
-- what that library builds. Clients of the source tree cannot show this up,
-- because Lake builds a module they import on demand.
let some protobufLib := (← getWorkspace).findLeanLib? `Protobuf
| do
IO.eprintln "the workspace defines no `Protobuf` library"
return 1
unless (← protobufLib.getModuleArray).any (·.name == `Protobuf.Json) do
IO.eprintln "`Protobuf.Json` is not a module of the `Protobuf` library"
return 1
-- Clients of a release do reach it as a library module, so build one and run
-- it: the module has to link, not merely resolve.
let clientDir : System.FilePath := "Test" / "Integration" / "Client"
let clientBuild ← IO.Process.spawn {
cmd := "lake"
args := #["build", "client"]
cwd := clientDir
stdin := .inherit
stdout := .inherit
stderr := .inherit
}
let clientBuildExit ← clientBuild.wait
if clientBuildExit != 0 then
return clientBuildExit
let client ← IO.Process.output {
cmd := "lake"
args := #["exe", "client"]
cwd := clientDir
}
if client.exitCode != 0 then
IO.eprint client.stderr
return client.exitCode
let expected := "{\"name\":\"payload\",\"number\":3}"
let rendered := client.stdout.trimAscii.toString
if rendered != expected then
IO.eprintln s!"json client printed {rendered}, expected {expected}"
return 1
return 0