-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
691 lines (621 loc) · 21.2 KB
/
Rakefile
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
require 'rake/classic_namespace'
require 'rake/clean'
CLEAN.include('gen_*.pir')
CLEAN.include('*/gen_*.pir')
CLEAN.include('*/*/gen_*.pir')
CLEAN.include('Test.pir')
CLEAN.include('build.yaml')
CLEAN.include('*.c')
CLEAN.include('*.o')
CLEAN.include('report')
CLOBBER.include('cardinal')
CLOBBER.include('*.pbc')
CLOBBER.include('report.tar.gz')
CLOBBER.include(['ctags_opt', 'tags'])
DEBUG = ENV['debug'] || false
ALTERNATIVE_RUBY = ENV['test_with'] || false
PARROT_CONFIG = ENV["PARROT_CONFIG"] || 'parrot_config'
$config = {}
$location = {
:parrot => "/parrot",
:perl6grammar => "/runtime/parrot/library/PGE/Perl6Grammar.pbc",
:nqp => "/runtime/parrot/library/nqp-rx.pbc",
:pct => "/runtime/parrot/library/PCT.pbc",
:pbc_to_exe => "/pbc_to_exe"
}
$tests = 0
$test_files = 0
$ok = 0
$nok = 0
$unknown = 0
$failures = 0
$expected_failures = 0
$unexpected_failures = []
$unexpected_passes = 0
$u_p_files = []
$missing = 0
$missing_files = []
$toomany = 0
$toomany_files = []
$issue_counts = Hash.new(0)
$issue_lacks = 0
$i_l_files = []
$comp_fails = 0
$c_f_files = []
$pl = false
$start = Time.now
$meta = Hash.new
$report = false
def clean?
return false if $nok > $expected_failures
return false if $failures > 0
return false if $unknown > 0
return false if $missing > 0
return false if $toomany > 0
return false if $issue_lacks > 0
return false if $comp_fails > 0
return true
end
def pl(word)
$pl ? word + "s" : word
end
def were
$pl ? "were" : "was"
end
def are
$pl ? "are" : "is"
end
def them
$pl ? "them" : "it"
end
def parrot(input, output="", grammar="", target="")
target = "--target=#{target}" if target != ""
output = "-o #{output}" if output != ""
puts "Running parrot: #{$config[:parrot]} #{grammar} #{target} #{output} #{input}" if DEBUG
sh "#{$config[:parrot]} #{grammar} #{target} #{output} #{input}"
end
def make_exe(pbc)
sh "#{$config[:pbc_to_exe]} cardinal.pbc"
end
def test(file, name="")
print "Adding #{file} as a test " if DEBUG
pir_file = file.gsub(/.t$/,'.pir')
if pir_file =~ /\//
pir_file.gsub!(/\/([^\/]+)$/) {"/gen_#$1"}
else
pir_file = "gen_#{pir_file}"
end
if name == ""
name = file.gsub(/.t$/,'').gsub(/^[0-9]+-/,'').gsub(/-/,'').gsub(/.*\//,'')
end
if ALTERNATIVE_RUBY
task name do
run_test file
end
else
file "t/#{pir_file}" => [:config, "t/#{file}", "src/gen_actions.pir", "src/gen_grammar.pir"] do
unless File.exists?('cardinal.pbc')
Task['cardinal.pbc'].invoke
end
begin
parrot("t/#{file}", "t/#{pir_file}", "cardinal.pbc", "pir")
rescue RuntimeError
File.open("t/#{pir_file}",'w') do |f|
f.write(".sub main :main\nsay 'FAILED TO COMPILE'\n.end")
end
end
end
puts "named #{name}" if DEBUG
task name => [:config, "t/#{pir_file}", "cardinal.pbc", "Test.pir"] do |t|
run_test pir_file, "#{t.scope.join(':')}:#{name}"
end
end
end
def get_report_file(filename)
dir = "report/t/" + File.dirname(filename)
dir.gsub!(/\/\./, '')
mkdir_p(dir)
ext = File.extname(filename)
fn = dir + "/" + File.basename(filename, ext)
fn += ".t"
fn.gsub!(/gen_/,'')
f = File.new(fn, 'w')
$meta['file_order'] += [fn.gsub(/report\//,'')]
return f
end
def run_test(file,name="")
puts file if DEBUG
name = file if name == ""
$test_files += 1
command = ALTERNATIVE_RUBY || $config[:parrot]
report_file = get_report_file(file) if $report
IO.popen("#{command} t/#{file}", "r") do |t|
begin
plan = t.readline
rescue EOFError
plan = "x"
end
puts plan if DEBUG
report_file.write(plan) if $report
if plan =~ /^1\.\.([0-9]+)/
tests = $1.to_i
$tests += tests
result = "#{$1} tests... "
ok = 0
nok = 0
unknown = 0
test = 0
t.readlines.each do |line|
test += 1
puts line if DEBUG
report_file.write(line) if $report
if line =~ /^ok #{test}/
ok += 1
if line =~ /TODO/
$unexpected_passes += 1
$u_p_files += [file]
end
else
if line =~ /^not ok #{test}/
nok += 1
if line =~ /(TODO|SKIP)/
$expected_failures += 1
if line =~ /See issue #([0-9]+)/
$issue_counts[$1] += 1
else
puts "Lacks issue." if DEBUG
$issue_lacks += 1
$i_l_files += [file]
end
else
$unexpected_failures += [file]
end
else
unknown += 1
end
end
end
result += "#{ok} ok "
$ok += ok
result += "#{nok} not ok"
$nok += nok
result += " #{unknown} unknown" if unknown > 0
$unknown += unknown
if test < tests
result += " MISSING TESTS"
$missing += 1
$missing_files += [file]
end
if test > tests
result += " TOO MANY TESTS"
$toomany += 1
$toomany_files += [file]
end
else
if plan =~ /FAILED TO COMPILE/
result = "Complete failure... failed to compile."
$comp_fails += 1
$c_f_files += [file]
else
result = "Complete failure... no plan given"
end
$failures += 1
end
report_file.close if $report
puts "Running #{name} #{result}"
end
end
desc "Produce a TAP archive"
task "report.tar.gz" do
$report = true
$meta['start_time'] = Time.now.to_i
$meta['file_order'] = Array.new
Task['test:all'].invoke
$meta['stop_time'] = Time.now.to_i
$meta['extra_properties'] = {
'Architecture' => get_arch,
'Platform' => get_platform,
'Branch' => get_branch,
'Submitter' => get_submitter,
'Commit' => get_commit
}
IO.popen("#{PARROT_CONFIG} revision", "r") do |p|
$meta['extra_properties']['Parrot Revision'] = p.readline.chomp.to_i
end
require 'yaml'
File.open('report/meta.yml','w') do |f|
YAML::dump($meta, f)
end
chdir 'report'
sh 'tar cfz ../report.tar.gz *'
chdir '..'
end
desc "Submit a smolder report."
task :smolder => "report.tar.gz" do
puts 'Creating a smolder report. This will take only a few minutes...', ''
command = 'curl '
contents = {
:username => 'parrot-autobot',
:password => 'qa_rocks',
:comments => 'Submit a smolder report.',
:architecture => "#{get_arch}",
:revision => "#{get_commit}",
:report_file => '@report.tar.gz'
}
url = 'http://smolder.parrot.org/app/projects/process_add_report/10'
contents.each do |k, v|
command << %Q(-F "#{k.to_s}=#{v}" )
end
command << url
`#{command} || exit 1`
if $?.exitstatus == 0
puts 'Your report sumitted.', 'You can see other recent reports at http://smolder.parrot.org/app/projects/smoke_reports/10'
else
puts 'Error occurred. Please contact Cardinal Team.', '#cardinal on irc.parrot.org'
end
end
desc "Determine configuration information"
task :config => "build.yaml" do
require 'yaml'
File.open("build.yaml","r") do |f|
$config.update(YAML.load(f))
end
puts "Configuring..."
puts "build_dir is #{$config[:build_dir]}"
err_msg = []
err_msg << $location[:parrot] unless File.exist?($config[:parrot])
err_msg << $location[:perl6grammar] unless File.exist?($config[:perl6grammar])
err_msg << $location[:nqp] unless File.exist?($config[:nqp])
err_msg << $location[:pct] unless File.exist?($config[:pct])
err_msg << $location[:pbc_to_exe] unless File.exist?($config[:pbc_to_exe])
if err_msg.size > 0
err_msg = err_msg.map {|c| 'build_dir' + c + ' does not exist'}
abort "aborted!\n" + err_msg.join("\n")
end
end
def get_arch
`uname -p`.chomp
end
def get_platform
`uname -s`.chomp
end
def get_branch
`git status`.split('\n')[0].split(' ')[3]
end
def get_submitter
submitter = ENV['SMOLDER_SUBMITTER']
submitter = "#{`git config --get user.name`} <#{`git config --get user.email`}>" if submitter == ''
return submitter
end
def get_commit
`git log -1 --pretty=format:%H`.chomp
end
file "build.yaml" do
require 'yaml'
config = {}
IO.popen("#{PARROT_CONFIG} build_dir", "r") do |p|
$config[:build_dir] = p.readline.chomp
end
print PARROT_CONFIG == 'parrot_config' ? "Detected " : "Provided "
puts "parrot_config reports that build_dir is #{$config[:build_dir]}."
$config[:parrot] = $config[:build_dir] + $location[:parrot]
$config[:perl6grammar] = $config[:build_dir] + $location[:perl6grammar]
$config[:nqp] = $config[:build_dir] + $location[:nqp]
$config[:pct] = $config[:build_dir] + $location[:pct]
$config[:pbc_to_exe] = $config[:build_dir] + $location[:pbc_to_exe]
File.open("build.yaml","w") do |f|
YAML.dump($config, f)
end
end
desc "Make the cardinal binary."
file "cardinal" => [:config, "cardinal.pbc"] do
make_exe("cardinal.pbc")
end
sources = FileList.new('cardinal.pir',
'src/parser/quote_expression.pir',
'src/gen_grammar.pir',
'src/gen_actions.pir',
'src/gen_builtins.pir')
file "cardinal.pbc" => sources do
parrot("cardinal.pir","cardinal.pbc")
end
file "src/gen_grammar.pir" => [:config, 'src/parser/grammar.pg'] do
parrot("src/parser/grammar.pg", "src/gen_grammar.pir", $config[:perl6grammar])
end
file "src/gen_actions.pir" => [:config, "src/parser/actions.pm"] do
parrot("src/parser/actions.pm","src/gen_actions.pir",$config[:nqp],'pir')
end
builtins = FileList.new("src/builtins/guts.pir", "src/builtins/control.pir", "src/builtins/say.pir", "src/builtins/cmp.pir", "src/builtins/op.pir", "src/classes/Object.pir", "src/classes/Exception.pir", "src/classes/NilClass.pir", "src/classes/String.pir", "src/classes/Numeric.pir", "src/classes/Integer.pir", "src/classes/Float.pir", "src/classes/Array.pir", "src/classes/Hash.pir", "src/classes/Range.pir", "src/classes/TrueClass.pir", "src/classes/FalseClass.pir", "src/classes/Kernel.pir", "src/classes/Time.pir", "src/classes/Math.pir", "src/classes/GC.pir", "src/classes/IO.pir", "src/classes/Proc.pir", "src/classes/File.pir", "src/classes/FileStat.pir", "src/classes/Dir.pir", "src/builtins/globals.pir", "src/builtins/eval.pir", "src/classes/Continuation.pir")
file "src/gen_builtins.pir" => builtins do
puts "Generating src/gen_builtins.pir"
File.open('src/gen_builtins.pir','w') do |f|
builtins.each do |b|
f.write(".include \"#{b}\"\n")
end
end
end
file "Test.pir" => ["cardinal.pbc", "Test.rb"] do
parrot("Test.rb", "Test.pir", "cardinal.pbc", "pir")
end
task :default => ["cardinal", "Test.pir"]
def get_ctags
ctags = `which ctags`.chomp
# any of exit statuses except 0 are fault
unless $?.exitstatus == 0
puts "Exuberant Ctags is needed to generates tags file."
exit 1
end
unless `#{ctags} --version`.scan(/Exuberant Ctags/).size > 0
puts "You have other version of ctags. Make sure Exuberant Ctags be current ctags instead of your own."
exit 1
end
ctags
end
namespace :tags do
desc "Generate ctags option file"
task :gen_option do
File.open "./ctags_opt", "w" do |f|
f.write "-f tags\n"
f.write "-R\n"
f.write "--totals\n"
f.write "--exclude=.git\n"
f.write "--exclude=.gitignore\n"
f.write "--exclude=*~\n"
f.write "--exclude=*.swp\n"
f.write "--exclude=*.rb\n"
f.write "--langdef=Parrot\n"
f.write "--langmap=Parrot:+.pir.pg.pasm.pmc\n"
f.write "--sort=yes\n"
f.write '--regex-Parrot=/^\.sub[ \t]*\'?(infix:)*([a-zA-Z0-9!#$%&*+,.\/:;<=>?@^_`\{\|\}~\-]+)\'?[ \t]*.*/\2/s,subroutine,subroutines/'
f.write "\n"
f.write '--regex-Parrot=/^rule[ \t]*([a-zA-Z0-9_]+)[ \t]*(:\"[a-zA-Z0-9!#$%&*+,.\/:;<=>?@^_`\{\|\}~\-]+\"*)*/\1/r,rule,rules/'
f.write "\n"
f.write '--regex-Parrot=/^token[ \t]*([a-zA-Z0-9_]+)[ \t]*(:\"[a-zA-Z0-9!#$%&*+,.\/:;<=>?@^_`\{\|\}~\-]+\"*)*/\1/r,token,tokens/'
end
puts "ctags_opt has been created"
end
desc "Generate tags for vim"
task :vim => [:gen_option] do
ctags = get_ctags
`#{ctags} --options=ctags_opt .`
FileUtils.rm_f "./ctags_opt"
end
desc "Generate tags for emacs"
task :emacs => [:gen_option] do
ctags = get_ctags
`#{ctags} -e --options=ctags_opt .`
FileUtils.rm_f "./ctags_opt"
end
end
namespace :test do |ns|
test "00-sanity.t"
test "01-stmts.t"
test "02-functions.t"
test "03-return.t"
test "04-indexed.t"
test "05-op-cmp.t"
test "07-loops.t"
test "08-class.t"
test "09-test.t"
test "10-regex.t"
test "11-slurpy.t"
test "12-gather.t"
test "99-other.t"
test "alias.t"
test "assignment.t"
test "blocks.t"
test "bool.t"
test "constants.t"
test "continuation.t"
test "freeze.t"
test "gc.t"
test "nil.t"
test "proc.t"
test "range.t"
test "splat.t"
test "time.t"
test "yield.t"
test "zip.t"
namespace :array do
test "array/array.t"
test "array/assign.t"
test "array/at.t"
test "array/clear.t"
test "array/collect.t"
test "array/compact.t"
test "array/concat.t"
test "array/count.t"
test "array/delete.t"
test "array/empty.t"
test "array/equals.t"
test "array/fetch.t"
test "array/fill.t"
test "array/first.t"
test "array/flatten.t"
test "array/grep.t"
test "array/include.t"
test "array/index.t"
test "array/insert.t"
test "array/intersection.t"
test "array/join.t"
test "array/mathop.t"
test "array/pop.t"
test "array/push.t"
test "array/reject.t"
test "array/replace.t"
test "array/reverse.t"
test "array/select.t"
test "array/shift.t"
test "array/slice.t"
test "array/sort.t"
test "array/to_s.t"
test "array/uniq.t"
test "array/values_at.t"
test "array/warray.t"
desc "Run tests on Array."
task :all => [:array, :assign, :at, :clear, :collect, :compact, :concat, :count, :delete, :empty, :equals, :fetch, :fill, :first, :flatten, :grep, :include, :index, :insert, :intersection, :join, :mathop, :pop, :push, :reject, :replace, :reverse, :select, :shift, :slice, :sort, :to_s, :uniq, :values_at, :warray]
end
namespace :file do
test "file/dir.t"
test "file/file.t"
test "file/stat.t"
desc "Run tests on File."
task :all => [:dir, :file, :stat]
end
namespace :hash do
test "hash/hash.t"
test "hash/exists.t"
desc "Run tests on Hash."
task :all => [:hash, :exists]
end
namespace :integer do
test "integer/integer.t"
test "integer/times.t"
test "integer/cmp.t"
test "integer/pred.t"
test "integer/chr.t"
test "integer/odd.t"
test "integer/even.t"
test "integer/round.t"
desc "Run tests on Integer."
task :all => [:integer, :times, :cmp, :pred, :chr, :odd, :even, :round]
end
namespace :numeric do
desc "Run tests on Numeric."
task :all
end
namespace :float do
test "float/to_f.t"
test "float/zero.t"
test "float/eql.t"
test "float/flo_eq.t"
desc "Run tests on Float"
task :all => [:to_f, :zero, :eql, :flo_eq]
end
namespace :kernel do
test "kernel/exit.t"
test "kernel/open.t"
test "kernel/sprintf.t"
desc "Run tests on Kernel."
task :all => [:exit, :open, :sprintf]
end
namespace :math do
test "math/functions.t"
desc "Run tests on Math."
task :all => [:functions]
end
namespace :range do
test "range/each.t"
test "range/infix-exclusive.t"
test "range/infix-inclusive.t"
test "range/membership-variants.t"
test "range/new.t"
test "range/to_a.t"
test "range/to_s.t"
test "range/tofrom-variants.t"
desc "Run tests on Range."
task :all => [:each, :infixexclusive, :infixinclusive, :membershipvariants, :new, :to_a, :to_s, :tofromvariants]
end
namespace :string do
test "string/add.t"
test "string/block.t"
test "string/capitalize.t"
test "string/chops.t"
test "string/cmp.t"
test "string/concat.t"
test "string/downcase.t"
test "string/empty.t"
test "string/eq.t"
test "string/mult.t"
test "string/new.t"
test "string/quote.t"
test "string/random_access.t"
test "string/reverse.t"
test "string/upcase.t"
desc "Run tests on String."
task :all => [:add, :block, :capitalize, :chops, :cmp, :concat, :downcase, :empty, :eq, :mult, :new, :quote, :random_access, :reverse, :upcase]
end
desc "Run basic tests."
task :basic => [:sanity, :stmts, :functions, :return, :indexed, :opcmp, :loops, :class, :test, :regex, :slurpy, :gather, :other, :alias, :assignment, :bool, :blocks, :constants, :continuation, :freeze, :gc, :nil, :proc, :range, :splat, :time, :yield, :zip]
desc "Run the entire test suite."
task :all => [:basic, "array:all", "file:all", "hash:all", "integer:all", "kernel:all", "math:all", "range:all", "string:all"] do
dur_seconds = Time.now.to_i - $start.to_i
dur_minutes = 0
while dur_seconds > 60
dur_seconds -= 60
dur_minutes += 1
end
puts "Test statistics:"
puts " The test suite took #{dur_minutes}:#{dur_seconds}."
puts " #{$tests} tests were run, from #{$test_files} files."
puts " #{$ok} tests passed, #{$unexpected_passes} of which were unexpected."
unless $u_p_files.empty?
$u_p_files.uniq!
$pl = $u_p_files.length > 1
puts " Unexpected passes were found in the following #{pl "file"}:"
$u_p_files.each do |pass|
puts " #{pass}"
end
end
$pl = $nok > 1
puts " #{$nok} #{pl "test"} failed, #{$expected_failures} of which were expected."
unless $unexpected_failures.empty?
$unexpected_failures.uniq!
$pl = $unexpected_failures.size > 1
puts " Unexpected #{pl "failure"} #{were} found in the following #{pl "file"}:"
$unexpected_failures.each do |fail|
puts " #{fail}"
end
end
$pl = $missing_files.size > 1
unless $missing_files.empty?
puts " There #{were} #{$missing} test #{pl "file"} that reported fewer results than were planned:"
$missing_files.uniq!
$missing_files.each do |missing|
puts " #{missing}"
end
end
$pl = $toomany_files.size > 1
unless $toomany_files.empty?
puts " There #{were} #{$toomany} test #{pl "file"} that reported more results than were planned:"
$toomany_files.uniq!
$toomany_files.each do |toomany|
puts " #{toomany}"
end
end
$pl = $unknown > 1
puts " There #{were} #{$unknown} unknown or confusing #{pl "result"}." if $unknown > 0
$pl = $failures > 1
puts " There #{were} #{$failures} complete #{pl "failure"}." if $failures > 0
$pl = $issue_lacks.size > 1
unless $i_l_files.empty?
puts " There #{were} #{$issue_lacks} #{pl "test"} that used todo or skip without noting an issue number, found in:"
$i_l_files.uniq!
$i_l_files.each do |file|
puts " #{file}"
end
end
$pl = $comp_fails > 1
unless $c_f_files.empty?
puts " There #{were} #{$comp_fails} #{pl "file"} that completely failed to compile:"
$c_f_files.uniq!
$c_f_files.each do |file|
puts " #{file}"
end
end
puts " -- CLEAN FOR COMMIT --" if clean?
end
desc "Run test:all *and* produce stats about known issues."
task :stats => [:all] do
$pl = $issue_counts.size > 1
unless $issue_counts.empty?
puts " The following #{are} the #{pl "issue"} currently known to affect the tests, and a count of the fails associated with #{them}:"
$issue_counts.each do |issue, count|
$pl = count > 1
puts " Issue ##{issue}: #{count} #{pl "fail"}"
end
else
puts " There are no issues currently known to affect the tests."
end
end
end