forked from dazuma/erl2ex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe2e_test.exs
274 lines (228 loc) · 8.88 KB
/
e2e_test.exs
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
defmodule E2ETest do
use ExUnit.Case
import Erl2exVendored.TestHelper
# Libraries that are working
@tag :e2e
test "erlware_commons" do
download_project("erlware_commons", "https://github.com/erlware/erlware_commons.git")
clean_dir("erlware_commons", "src_ex")
convert_dir("erlware_commons", "src", "src_ex",
include_dir: project_path("erlware_commons", "include"),
auto_export_suffix: "_test_",
auto_export_suffix: "_test")
copy_dir("erlware_commons", "test", "src_ex")
compile_dir("erlware_commons", "src_ex",
display_output: true,
DEFINE_namespaced_types: "true")
run_eunit_tests(
[:ec_plists],
"erlware_commons", "src_ex", display_output: true)
end
@tag :e2e
test "getopt" do
download_project("getopt", "https://github.com/jcomellas/getopt.git")
clean_dir("getopt", "src_ex")
convert_dir("getopt", "src", "src_ex")
copy_dir("getopt", "test", "src_ex")
compile_dir("getopt", "src_ex", display_output: true)
run_eunit_tests(
[:getopt_test],
"getopt", "src_ex", display_output: true)
end
@tag :e2e
test "gproc" do
download_project("gproc", "https://github.com/uwiger/gproc.git")
clean_dir("gproc", "src_ex")
convert_dir("gproc", "src", "src_ex",
include_dir: project_path("gproc", "include"),
auto_export_suffix: "_test_",
auto_export_suffix: "_test")
copy_dir("gproc", "test", "src_ex", ["gproc_tests.erl", "gproc_test_lib.erl"])
copy_file("gproc", "src/gproc.app.src", "src_ex/gproc.app")
compile_dir("gproc", "src_ex", display_output: true)
run_eunit_tests(
[:gproc_tests],
"gproc", "src_ex", display_output: true)
end
@tag :e2e
test "idna" do
download_project("idna", "https://github.com/benoitc/erlang-idna.git")
clean_dir("idna", "src_ex")
convert_dir("idna", "src", "src_ex")
copy_dir("idna", "test", "src_ex")
compile_dir("idna", "src_ex", display_output: true)
run_eunit_tests(
[:idna_test],
"idna", "src_ex", display_output: true)
end
@tag :e2e
test "jsx" do
download_project("jsx", "https://github.com/talentdeficit/jsx.git")
clean_dir("jsx", "src_ex")
convert_dir("jsx", "src", "src_ex", auto_export_suffix: "_test_")
compile_dir("jsx", "src_ex", display_output: true)
run_eunit_tests(
[
:jsx,
:jsx_config,
:jsx_decoder,
:jsx_encoder,
:jsx_parser,
:jsx_to_json,
:jsx_to_term,
:jsx_verify
],
"jsx", "src_ex", display_output: true)
end
@tag :e2e
test "mochiweb" do
download_project("mochiweb", "https://github.com/mochi/mochiweb.git")
clean_dir("mochiweb", "src_ex")
convert_dir("mochiweb", "src", "src_ex",
include_dir: project_path("mochiweb", "include"))
copy_dir("mochiweb", "test", "src_ex")
compile_dir("mochiweb", "src_ex", display_output: true)
run_eunit_tests(
[
:mochiweb_base64url_tests,
:mochiweb_html_tests,
:mochiweb_http_tests,
:mochiweb_request_tests,
:mochiweb_socket_server_tests,
:mochiweb_tests,
:mochiweb_websocket_tests
],
"mochiweb", "src_ex", display_output: true)
end
@tag :e2e
test "poolboy" do
download_project("poolboy", "https://github.com/devinus/poolboy.git")
clean_dir("poolboy", "src_ex")
convert_dir("poolboy", "src", "src_ex")
copy_dir("poolboy", "test", "src_ex")
compile_dir("poolboy", "src_ex", display_output: true)
run_eunit_tests(
[:poolboy],
"poolboy", "src_ex", display_output: true)
end
@tag :e2e
test "ranch" do
download_project("ranch", "https://github.com/ninenines/ranch.git")
clean_dir("ranch", "src_ex")
convert_dir("ranch", "src", "src_ex")
compile_dir("ranch", "src_ex", display_output: true)
# Not sure how to run tests
end
# Libraries that are not yet working
# Fails because a macro appears as a record name.
@tag :skip
test "bbmustache" do
download_project("bbmustache", "https://github.com/soranoba/bbmustache.git")
clean_dir("bbmustache", "src_ex")
convert_dir("bbmustache", "src", "src_ex")
copy_dir("bbmustache", "test", "src_ex")
compile_dir("bbmustache", "src_ex", display_output: true)
run_eunit_tests(
[:bbmustache_tests],
"bbmustache", "src_ex", display_output: true)
end
# Fails because cowlib fails
@tag :skip
test "cowboy" do
download_project("cowboy", "https://github.com/ninenines/cowboy.git")
download_project("cowlib", "https://github.com/ninenines/cowlib.git")
download_project("ranch", "https://github.com/ninenines/ranch.git")
clean_dir("cowboy", "src_ex")
convert_dir("cowboy", "src", "src_ex",
lib_dir: %{cowlib: project_path("cowlib"), ranch: project_path("ranch")})
compile_dir("cowboy", "src_ex", display_output: true)
# Not sure how to run tests
end
# Fails because a comprehension contains a macro invocation
@tag :skip
test "cowlib" do
download_project("ranch", "https://github.com/ninenines/cowlib.git")
clean_dir("cowlib", "src_ex")
convert_dir("cowlib", "src", "src_ex",
include_dir: project_path("cowlib", "include"))
compile_dir("cowlib", "src_ex", display_output: true)
# Not sure how to run tests
end
# In progress.
@tag :skip
@tag timeout: 300000
test "elixir" do
download_project("elixir", "https://github.com/elixir-lang/elixir.git")
File.rm_rf!(project_path("elixir", "lib/elixir/ebin"))
clean_dir("elixir", "lib/elixir/src2")
clean_dir("elixir", "lib/elixir/src_ex")
# Run yecc on the elixir_parser source.
copy_file("elixir", "lib/elixir/src/elixir_parser.yrl", "lib/elixir/src2/elixir_parser.yrl")
run_cmd("erl", ["-run", "yecc", "file", "elixir_parser", "-run", "init", "stop", "-noshell"],
name: "elixir", path: "lib/elixir/src2")
# Convert
convert_dir("elixir", "lib/elixir/src", "lib/elixir/src_ex")
convert_dir("elixir", "lib/elixir/src2", "lib/elixir/src_ex")
# elixir_bootstrap.erl generates __info__ functions so can't be converted for now
File.rm!(project_path("elixir", "lib/elixir/src_ex/elixir_bootstrap.ex"))
File.cp!(project_path("elixir", "lib/elixir/src/elixir_bootstrap.erl"),
project_path("elixir", "lib/elixir/src_ex/elixir_bootstrap.erl"))
# Create a dummy elixir_parser.erl so rebar doesn't generate it.
create_file("elixir", "lib/elixir/src/elixir_parser.erl",
"""
-module(elixir_parser).
""")
# Converted code needs Enum.reduce
create_file("elixir", "lib/elixir/src_ex/Elixir.Enum.erl",
"""
-module('Elixir.Enum').
-export([reduce/3]).
reduce(List, Acc, Fn) -> lists:foldl(Fn, Acc, List).
""")
# Compile each elixir file separately; otherwise newly compiled modules will
# be added to the VM, causing compatibility issues between old and new.
compile_dir_individually("elixir", "lib/elixir/src_ex",
display_output: true, display_cmd: true, output: "../ebin")
run_cmd("make", ["lib/elixir/src/elixir.app.src"], name: "elixir")
run_cmd(project_path("elixir", "rebar"), ["compile"], name: "elixir", path: "lib/elixir")
run_cmd("make", ["test"], name: "elixir")
end
# Fails because a binary literal contains a macro invocation returning a list.
@tag :skip
test "eredis" do
download_project("eredis", "https://github.com/wooga/eredis.git")
clean_dir("eredis", "src_ex")
convert_dir("eredis", "src", "src_ex",
include_dir: project_path("eredis", "include"))
copy_dir("eredis", "test", "src_ex")
compile_dir("eredis", "src_ex", display_output: true)
run_eunit_tests(
[:eredis_parser_tests, :eredis_sub_tests, :eredis_tests],
"eredis", "src_ex", display_output: true)
end
# Fails because a fully qualified macro appears in a typespec
@tag :skip
test "goldrush" do
download_project("goldrush", "https://github.com/DeadZen/goldrush.git")
clean_dir("goldrush", "src_ex")
convert_dir("goldrush", "src", "src_ex",
auto_export_suffix: "_test_",
auto_export_suffix: "_test")
compile_dir("goldrush", "src_ex", display_output: true)
run_eunit_tests(
[:glc],
"goldrush", "src_ex", display_output: true)
end
# Fails because of a strange missing file in the public_key application.
@tag :skip
test "ssl_verify_fun" do
download_project("ssl_verify_fun", "https://github.com/deadtrickster/ssl_verify_fun.erl.git")
clean_dir("ssl_verify_fun", "src_ex")
convert_dir("ssl_verify_fun", "src", "src_ex")
copy_dir("ssl_verify_fun", "test", "src_ex")
compile_dir("ssl_verify_fun", "src_ex", display_output: true)
run_eunit_tests(
[:ssl_verify_fingerprint_tests, :ssl_verify_hostname_tests, :ssl_verify_pk_tests],
"ssl_verify_fun", "src_ex", display_output: true)
end
end