From 25e0547679021f716caf51cc30958e91302d262a Mon Sep 17 00:00:00 2001 From: Joeri Samson Date: Sun, 16 Aug 2009 03:25:49 +0200 Subject: [PATCH 01/32] Use real true and false when testing GC --- t/gc.t | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/gc.t b/t/gc.t index 4b457b0..84d9f3c 100644 --- a/t/gc.t +++ b/t/gc.t @@ -5,13 +5,13 @@ plan 4 # TODO rework this test after we can loop thru all the object in the system, then we can verify they were destroyed status = GC.disable -is status, 'false', '.disable on GC' +is status, false, '.disable on GC' status = GC.enable -is status, 'true', '.enable on GC' +is status, true, '.enable on GC' status = GC.disable -is status, 'false', '.disable on GC' +is status, false, '.disable on GC' GC.start pass '.start on GC' From b7a16cfd98e4df142aaff3f592bc3046dfac7a00 Mon Sep 17 00:00:00 2001 From: Joeri Samson Date: Sun, 16 Aug 2009 22:33:51 +0200 Subject: [PATCH 02/32] Remove postfix ++ and -- --- src/builtins/op.pir | 18 ------------------ src/classes/Range.pir | 5 +++-- src/parser/grammar.pg | 5 ----- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/src/builtins/op.pir b/src/builtins/op.pir index 4dc10af..22e2463 100644 --- a/src/builtins/op.pir +++ b/src/builtins/op.pir @@ -102,24 +102,6 @@ src/builtins/op.pir - Cardinal ops .return ($P0) .end - -## autoincrement -.sub 'postfix:++' :multi(_) - .param pmc a - $P0 = clone a - inc a - .return ($P0) - #.return (a) -.end - -.sub 'postfix:--' :multi(_) - .param pmc a - $P0 = clone a - dec a - .return ($P0) -.end - - =back =cut diff --git a/src/classes/Range.pir b/src/classes/Range.pir index 1a6df49..3ff6130 100644 --- a/src/classes/Range.pir +++ b/src/classes/Range.pir @@ -328,7 +328,8 @@ Generate the next element at the front of the CardinalRange. .local pmc from, fromexc, value from = getattribute self, '$!from' fromexc = getattribute self, '$!from_exclusive' - value = 'postfix:++'(from) + value = clone from + inc from unless fromexc goto have_value value = clone from have_value: @@ -353,7 +354,7 @@ Return true if there are any more values to iterate over. fromexc = getattribute self, '$!from_exclusive' unless fromexc goto have_value from = clone from - 'postfix:++'(from) + inc from have_value: $I0 = self.'!to_test'(from) .return ($I0) diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg index ad65b78..6007d0a 100644 --- a/src/parser/grammar.pg +++ b/src/parser/grammar.pg @@ -551,11 +551,6 @@ proto 'infix:/' is equiv('infix:*') { ... } proto 'infix:%' is equiv('infix:*') is pirop('mod') { ... } -proto 'postfix:++' is tighter('infix:*') - is pirop('n_add') { ... } - -proto 'postfix:--' is tighter('infix:*') - is pirop('n_sub') { ... } # #proto 'prefix:+' is tighter('infix:*') { ... } #proto 'prefix:-' is equiv('prefix:+') { ... } From 6b1eca1e1359821dfdc26d701bf86b5d682c60eb Mon Sep 17 00:00:00 2001 From: Joeri Samson Date: Sun, 16 Aug 2009 22:42:54 +0200 Subject: [PATCH 03/32] Make all proto ops look the same --- src/parser/grammar.pg | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg index 6007d0a..455863a 100644 --- a/src/parser/grammar.pg +++ b/src/parser/grammar.pg @@ -190,8 +190,6 @@ rule args { rule 'arg' is optable { ... } -proto 'infix:=' is precedence('1') is pasttype('copy') is lvalue(1) { ... } - token basic_primary { | {*} #= literal | {*} #= funcall @@ -488,10 +486,10 @@ proto 'infix:&=' is equiv('infix:=') { ... } proto 'infix:~=' is equiv('infix:=') { ... } -proto infix:«>>=» is equiv('infix:=') +proto 'infix:>>=' is equiv('infix:=') is pirop('shr') { ... } -proto infix:«<<=» is equiv('infix:=') +proto 'infix:<<=' is equiv('infix:=') is pirop('shl') { ... } proto 'infix:&&=' is equiv('infix:=') @@ -521,23 +519,23 @@ proto 'infix:!=' is equiv('infix:==') { ... } proto 'infix:=~' is equiv('infix:==') { ... } proto 'infix:!~' is equiv('infix:==') { ... } proto 'infix:===' is equiv('infix:==') { ... } -proto infix:«<=>» is equiv('infix:==') { ... } +proto 'infix:<=>' is equiv('infix:==') { ... } -proto infix:«>» is tighter('infix:===') { ... } -proto infix:«<» is tighter('infix:===') { ... } -proto infix:«<=» is tighter('infix:===') { ... } -proto infix:«>=» is tighter('infix:===') { ... } +proto 'infix:>' is tighter('infix:===') { ... } +proto 'infix:<' is equiv('infix:>') { ... } +proto 'infix:<=' is equiv('infix:>') { ... } +proto 'infix:>=' is equiv('infix:>') { ... } proto 'infix:|' is tighter('infix:<=') { ... } proto 'infix:^' is equiv('infix:|') { ... } proto 'infix:&' is tighter('infix:|') { ... } -proto infix:«<<» is tighter('infix:&') { ... } -proto infix:«>>» is equiv(infix:«<<») { ... } +proto 'infix:<<' is tighter('infix:&') { ... } +proto 'infix:>>' is equiv('infix:<<') { ... } -proto 'infix:+' is tighter(infix:«<<») { ... } +proto 'infix:+' is tighter('infix:<<') { ... } proto 'infix:-' is equiv('infix:+') { ... } #is pirop('sub') { ... } From fc405838227a305c48d53460a5b9ad372222c260 Mon Sep 17 00:00:00 2001 From: Joeri Samson Date: Sun, 16 Aug 2009 22:43:28 +0200 Subject: [PATCH 04/32] Add support for () in expressions --- src/builtins/op.pir | 5 +++++ src/parser/grammar.pg | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/builtins/op.pir b/src/builtins/op.pir index 22e2463..d482cec 100644 --- a/src/builtins/op.pir +++ b/src/builtins/op.pir @@ -102,6 +102,11 @@ src/builtins/op.pir - Cardinal ops .return ($P0) .end +.sub 'circumfix:( )' + .param pmc a + .return (a) +.end + =back =cut diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg index 455863a..a1bf083 100644 --- a/src/parser/grammar.pg +++ b/src/parser/grammar.pg @@ -557,3 +557,5 @@ proto 'infix:%' is equiv('infix:*') proto 'term:' is tighter('infix:*') is parsed(&primary) { ... } + +proto 'circumfix:( )' is equiv('term:') { ... } From 7f1a943ec139c5d3500f4cc6b7d6e02ebf1e7598 Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Mon, 17 Aug 2009 13:39:14 -0700 Subject: [PATCH 05/32] Floats need to have at least one digit prior to the radix. --- src/parser/grammar.pg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg index ad65b78..897ca82 100644 --- a/src/parser/grammar.pg +++ b/src/parser/grammar.pg @@ -423,7 +423,7 @@ token literal { } token float { - '-'? \d* '.' \d+ + '-'? \d+ '.' \d+ {*} } From 298dbf055d6fb5909c60506caa96bef5b0f39edc Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Mon, 17 Aug 2009 14:01:32 -0700 Subject: [PATCH 06/32] foo++ and foo-- don't exist in Ruby --- src/parser/grammar.pg | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg index 897ca82..c17c80e 100644 --- a/src/parser/grammar.pg +++ b/src/parser/grammar.pg @@ -551,12 +551,6 @@ proto 'infix:/' is equiv('infix:*') { ... } proto 'infix:%' is equiv('infix:*') is pirop('mod') { ... } -proto 'postfix:++' is tighter('infix:*') - is pirop('n_add') { ... } - -proto 'postfix:--' is tighter('infix:*') - is pirop('n_sub') { ... } -# #proto 'prefix:+' is tighter('infix:*') { ... } #proto 'prefix:-' is equiv('prefix:+') { ... } #proto 'prefix:!' is equiv('prefix:+') { ... } From 7ae0541fa6fd8f8a9536ed3f67d7713dca5347bd Mon Sep 17 00:00:00 2001 From: Joeri Samson Date: Sun, 16 Aug 2009 22:33:51 +0200 Subject: [PATCH 07/32] Remove postfix ++ and -- --- src/builtins/op.pir | 18 ------------------ src/classes/Range.pir | 5 +++-- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/builtins/op.pir b/src/builtins/op.pir index 4dc10af..22e2463 100644 --- a/src/builtins/op.pir +++ b/src/builtins/op.pir @@ -102,24 +102,6 @@ src/builtins/op.pir - Cardinal ops .return ($P0) .end - -## autoincrement -.sub 'postfix:++' :multi(_) - .param pmc a - $P0 = clone a - inc a - .return ($P0) - #.return (a) -.end - -.sub 'postfix:--' :multi(_) - .param pmc a - $P0 = clone a - dec a - .return ($P0) -.end - - =back =cut diff --git a/src/classes/Range.pir b/src/classes/Range.pir index 1a6df49..3ff6130 100644 --- a/src/classes/Range.pir +++ b/src/classes/Range.pir @@ -328,7 +328,8 @@ Generate the next element at the front of the CardinalRange. .local pmc from, fromexc, value from = getattribute self, '$!from' fromexc = getattribute self, '$!from_exclusive' - value = 'postfix:++'(from) + value = clone from + inc from unless fromexc goto have_value value = clone from have_value: @@ -353,7 +354,7 @@ Return true if there are any more values to iterate over. fromexc = getattribute self, '$!from_exclusive' unless fromexc goto have_value from = clone from - 'postfix:++'(from) + inc from have_value: $I0 = self.'!to_test'(from) .return ($I0) From 6061f7e02eef32f0ea94fa2f1e2d3c37c8210254 Mon Sep 17 00:00:00 2001 From: Joeri Samson Date: Sun, 16 Aug 2009 03:25:49 +0200 Subject: [PATCH 08/32] Use real true and false when testing GC --- t/gc.t | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/gc.t b/t/gc.t index 4b457b0..84d9f3c 100644 --- a/t/gc.t +++ b/t/gc.t @@ -5,13 +5,13 @@ plan 4 # TODO rework this test after we can loop thru all the object in the system, then we can verify they were destroyed status = GC.disable -is status, 'false', '.disable on GC' +is status, false, '.disable on GC' status = GC.enable -is status, 'true', '.enable on GC' +is status, true, '.enable on GC' status = GC.disable -is status, 'false', '.disable on GC' +is status, false, '.disable on GC' GC.start pass '.start on GC' From 0560029ccd16ebee006b62937f9717ba8c59e101 Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Mon, 17 Aug 2009 16:31:37 -0700 Subject: [PATCH 09/32] Actually have GC's methods return true and false, rather than strings. --- src/classes/GC.pir | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/classes/GC.pir b/src/classes/GC.pir index 1e39551..93a2c47 100644 --- a/src/classes/GC.pir +++ b/src/classes/GC.pir @@ -54,12 +54,10 @@ Perform initializations and create the GC class $P1 = 1 setattribute self, '$!disabled', $P1 collectoff - $P0 = new 'CardinalString' - $P0 = 'false' + $P0 = get_hll_global 'false' .return ($P0) already_disabled: - $P0 = new 'CardinalString' - $P0 = 'true' + $P0 = get_hll_global 'true' .return ($P0) .end @@ -68,16 +66,14 @@ Perform initializations and create the GC class if $P0 == 1 goto enable goto already_enabled already_enabled: - $P0 = new 'CardinalString' - $P0 = 'false' + $P0 = get_hll_global 'false' .return ($P0) enable: $P1 = new 'CardinalInteger' $P1 = 0 setattribute self, '$!disabled', $P1 collecton - $P0 = new 'CardinalString' - $P0 = 'true' + $P0 = get_hll_global 'true' .return ($P0) .end From 171e24bc6fc3a8840be6b1bb57834384a9a5a759 Mon Sep 17 00:00:00 2001 From: Joeri Samson Date: Sun, 16 Aug 2009 22:42:54 +0200 Subject: [PATCH 10/32] Make all proto ops look the same --- src/parser/grammar.pg | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg index c17c80e..3b5fcc6 100644 --- a/src/parser/grammar.pg +++ b/src/parser/grammar.pg @@ -190,8 +190,6 @@ rule args { rule 'arg' is optable { ... } -proto 'infix:=' is precedence('1') is pasttype('copy') is lvalue(1) { ... } - token basic_primary { | {*} #= literal | {*} #= funcall @@ -488,10 +486,10 @@ proto 'infix:&=' is equiv('infix:=') { ... } proto 'infix:~=' is equiv('infix:=') { ... } -proto infix:«>>=» is equiv('infix:=') +proto 'infix:>>=' is equiv('infix:=') is pirop('shr') { ... } -proto infix:«<<=» is equiv('infix:=') +proto 'infix:<<=' is equiv('infix:=') is pirop('shl') { ... } proto 'infix:&&=' is equiv('infix:=') @@ -521,23 +519,23 @@ proto 'infix:!=' is equiv('infix:==') { ... } proto 'infix:=~' is equiv('infix:==') { ... } proto 'infix:!~' is equiv('infix:==') { ... } proto 'infix:===' is equiv('infix:==') { ... } -proto infix:«<=>» is equiv('infix:==') { ... } +proto 'infix:<=>' is equiv('infix:==') { ... } -proto infix:«>» is tighter('infix:===') { ... } -proto infix:«<» is tighter('infix:===') { ... } -proto infix:«<=» is tighter('infix:===') { ... } -proto infix:«>=» is tighter('infix:===') { ... } +proto 'infix:>' is tighter('infix:===') { ... } +proto 'infix:<' is equiv('infix:>') { ... } +proto 'infix:<=' is equiv('infix:>') { ... } +proto 'infix:>=' is equiv('infix:>') { ... } proto 'infix:|' is tighter('infix:<=') { ... } proto 'infix:^' is equiv('infix:|') { ... } proto 'infix:&' is tighter('infix:|') { ... } -proto infix:«<<» is tighter('infix:&') { ... } -proto infix:«>>» is equiv(infix:«<<») { ... } +proto 'infix:<<' is tighter('infix:&') { ... } +proto 'infix:>>' is equiv('infix:<<') { ... } -proto 'infix:+' is tighter(infix:«<<») { ... } +proto 'infix:+' is tighter('infix:<<') { ... } proto 'infix:-' is equiv('infix:+') { ... } #is pirop('sub') { ... } From 4ca9cd219b748321d11dfabde356af3cf57bab21 Mon Sep 17 00:00:00 2001 From: Joeri Samson Date: Mon, 17 Aug 2009 04:43:28 +0800 Subject: [PATCH 11/32] Add support for () in expressions Signed-off-by: Ted Reed --- src/builtins/op.pir | 5 +++++ src/parser/grammar.pg | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/builtins/op.pir b/src/builtins/op.pir index 22e2463..d482cec 100644 --- a/src/builtins/op.pir +++ b/src/builtins/op.pir @@ -102,6 +102,11 @@ src/builtins/op.pir - Cardinal ops .return ($P0) .end +.sub 'circumfix:( )' + .param pmc a + .return (a) +.end + =back =cut diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg index 3b5fcc6..457e9b6 100644 --- a/src/parser/grammar.pg +++ b/src/parser/grammar.pg @@ -556,3 +556,5 @@ proto 'infix:%' is equiv('infix:*') proto 'term:' is tighter('infix:*') is parsed(&primary) { ... } + +proto 'circumfix:( )' is equiv('term:') { ... } From 37af6e91727faa76600c251ffa8cd6cff1a24328 Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Mon, 17 Aug 2009 17:55:34 +0800 Subject: [PATCH 12/32] fix build with make Signed-off-by: Ted Reed --- build/Makefile.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/Makefile.in b/build/Makefile.in index babbd44..5a75e00 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -48,14 +48,15 @@ BUILTINS_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/Integer.pir \ src/classes/Array.pir \ src/classes/Hash.pir \ - src/classes/Any.pir \ src/classes/Range.pir \ - src/classes/Bool.pir \ + src/classes/TrueClass.pir \ + src/classes/FalseClass.pir \ src/classes/Kernel.pir \ src/classes/Time.pir \ src/classes/Math.pir \ From c34fa1833df80cf89fe3ea00d3f75edb494282d3 Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Mon, 17 Aug 2009 19:21:57 -0700 Subject: [PATCH 13/32] Cause the Makefile to use the rakefile for testing. --- build/Makefile.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/Makefile.in b/build/Makefile.in index 5a75e00..97669c8 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -133,13 +133,13 @@ help: @echo "" test: all - $(PERL) t/harness + rake test:all arraytest: all - $(PERL) t/harness --tests-from-dir=array + rake test:array:all hashtest: all - $(PERL) t/harness --tests-from-dir=hash + rake test:hash:all # this target has nothing to do testclean: From 66a059aea40a201a79c5c28fa1e7cf3cf8315d25 Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Tue, 18 Aug 2009 22:56:09 -0700 Subject: [PATCH 14/32] Miscellaneous changes/fixes to the Rakefile. * Now has targets for clean/clobber. * Main targets have descriptions. * As a result, the main targets can be listed with 'rake -T'. * Tests now generate cardinal.pbc on demand, without depending on it. * Tests output the full task name with namespace when running. --- Rakefile | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 4e06698..73e99a0 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,16 @@ +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') +CLOBBER.include('cardinal') +CLOBBER.include('*.pbc') + DEBUG = ENV['debug'] || false ALTERNATIVE_RUBY = ENV['test_with'] || false CONFIG = {} @@ -75,11 +88,14 @@ def test(file, name="") 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 parrot("t/#{file}", "t/#{pir_file}", "cardinal.pbc", "pir") end puts "named #{name}" if DEBUG - task name => [:config, "t/#{pir_file}", "cardinal.pbc", "Test.pir"] do - run_test pir_file, name + task name => [:config, "t/#{pir_file}", "cardinal.pbc", "Test.pir"] do |t| + run_test pir_file, "#{t.scope.join(':')}:#{name}" end end end @@ -153,10 +169,11 @@ def run_test(file,name="") result = "Complete failure... no plan given" $failures += 1 end - puts "Running test #{name} #{result}" + puts "Running #{name} #{result}" end end +desc "Determine configuration information" task :config => "build.yaml" do require 'yaml' File.open("build.yaml","r") do |f| @@ -187,6 +204,7 @@ file "build.yaml" do end end +desc "Make the cardinal binary." file "cardinal" => [:config, "cardinal.pbc"] do make_exe("cardinal.pbc") end @@ -292,6 +310,7 @@ namespace :test do |ns| test "array/values_at.t" test "array/warray.t" + desc "Run tests on Array." task :all => [:array, :assign, :at, :clear, :collect, :compact, :concat, :delete, :empty, :equals, :fetch, :fill, :first, :flatten, :grep, :include, :index, :insert, :intersection, :join, :mathop, :nitems, :pop, :push, :reject, :replace, :reverse, :shift, :slice, :sort, :to_s, :uniq, :values_at, :warray] end @@ -300,6 +319,7 @@ namespace :test do |ns| test "file/file.t" test "file/stat.t" + desc "Run tests on File." task :all => [:dir, :file, :stat] end @@ -307,6 +327,7 @@ namespace :test do |ns| test "hash/hash.t" test "hash/exists.t" + desc "Run tests on Hash." task :all => [:hash, :exists] end @@ -315,6 +336,7 @@ namespace :test do |ns| test "integer/times.t" test "integer/cmp.t" + desc "Run tests on Integer." task :all => [:integer, :times, :cmp] end @@ -323,12 +345,14 @@ namespace :test do |ns| 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 @@ -342,6 +366,7 @@ namespace :test do |ns| 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 @@ -362,10 +387,14 @@ namespace :test do |ns| 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 @@ -426,6 +455,7 @@ namespace :test do |ns| 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? From 3004f32a290923cca26c4fdf18203b49838bd61e Mon Sep 17 00:00:00 2001 From: Joeri Samson Date: Wed, 19 Aug 2009 21:30:39 +0200 Subject: [PATCH 15/32] Remove unused rule --- src/parser/grammar.pg | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg index a1bf083..a018208 100644 --- a/src/parser/grammar.pg +++ b/src/parser/grammar.pg @@ -299,13 +299,6 @@ rule functiondef { {*} } -rule bodystmt { - - ? - ? - ? -} - rule argdecl { ['(' From 686f030194fb6d4276f812921eecb5234b727026 Mon Sep 17 00:00:00 2001 From: Joeri Samson Date: Wed, 19 Aug 2009 21:30:53 +0200 Subject: [PATCH 16/32] Make puts and friends return nil --- src/builtins/say.pir | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/builtins/say.pir b/src/builtins/say.pir index bafc63f..08e26c5 100644 --- a/src/builtins/say.pir +++ b/src/builtins/say.pir @@ -18,19 +18,20 @@ builtin functions for Ruby. print $P0 goto iter_loop iter_end: - .return () + $P0 = get_hll_global 'nil' + .return($P0) .end .sub 'puts' .param pmc args :slurpy $S0 = join "\n", args - 'print'($S0, "\n") + .tailcall 'print'($S0, "\n") .end .sub 'p' .param pmc args :slurpy $S0 = join "\n", args - 'print'($S0, "\n") + .tailcall 'print'($S0, "\n") .end .sub 'readline' @@ -44,7 +45,7 @@ builtin functions for Ruby. .param pmc fmt .param pmc args :slurpy $P0 = get_hll_global ['Kernel'], '!CARDINALMETA' - $P0.'printf'(fmt, args :flat) + .tailcall $P0.'printf'(fmt, args :flat) .end .sub 'sprintf' From e1abfa064ce2091506909f88d42c9a95bdef09c2 Mon Sep 17 00:00:00 2001 From: Joeri Samson Date: Sat, 22 Aug 2009 23:36:44 +0200 Subject: [PATCH 17/32] Enable trailing whitespace Also add trailing whitespace to sanity test as a primitive regression test --- src/parser/grammar.pg | 2 +- t/00-sanity.t | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg index 9185e35..f296f02 100644 --- a/src/parser/grammar.pg +++ b/src/parser/grammar.pg @@ -29,7 +29,7 @@ rule stmts { <.term>?[ [<.term>+ | <.before > | $ | ] ]* {*} } -token term { \n | ';' } +token term { \h*\n | \h*';' } token end_block { <.ws> [ 'end' | '}' ] } token basic_stmt { diff --git a/t/00-sanity.t b/t/00-sanity.t index 44eb1b8..91d6d0e 100644 --- a/t/00-sanity.t +++ b/t/00-sanity.t @@ -5,13 +5,13 @@ puts "1..5" if 1 # comments work! # -puts "ok 1" - +puts "ok 1" + puts "ok 2" ; puts "ok 3" - + print "ok "; print 1 + 3; print "\n" - + print "ok #{ 2 * 2 + 1 }\n" - + ; ; ; # Trailing whitespace should not be a problem for the code From f34c51f1e37452acadd654d030b6e84c6c2ab857 Mon Sep 17 00:00:00 2001 From: Joeri Samson Date: Sun, 23 Aug 2009 02:40:53 +0200 Subject: [PATCH 18/32] Removes two unused rules from grammar --- src/parser/actions.pm | 4 ---- src/parser/grammar.pg | 11 ----------- 2 files changed, 15 deletions(-) diff --git a/src/parser/actions.pm b/src/parser/actions.pm index 2e7bf05..750d1ad 100644 --- a/src/parser/actions.pm +++ b/src/parser/actions.pm @@ -408,10 +408,6 @@ method else($/) { make $.ast(); } -method ensure($/) { - make $.ast(); -} - method while_stmt($/) { my $cond := $.ast(); my $body := $.ast(); diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg index f296f02..14b355b 100644 --- a/src/parser/grammar.pg +++ b/src/parser/grammar.pg @@ -258,17 +258,6 @@ token else { {*} } -token ensure { - 'ensure' <.ws> - {*} -} - -rule rescue { - # XXX check - ['rescue' <.then> ]+ - {*} -} - token control_command { | 'next' {*} #= next | 'break' {*} #= break From c6d933485b418706442d444f03821d4b073e4496 Mon Sep 17 00:00:00 2001 From: Danius Michaelides Date: Sun, 23 Aug 2009 22:55:45 +0800 Subject: [PATCH 19/32] Array#nitems() has been removed from 1.9. Signed-off-by: Ted Reed --- Rakefile | 3 +-- src/classes/Array.pir | 16 ---------------- t/array/nitems.t | 16 ---------------- 3 files changed, 1 insertion(+), 34 deletions(-) delete mode 100644 t/array/nitems.t diff --git a/Rakefile b/Rakefile index 73e99a0..a72e015 100644 --- a/Rakefile +++ b/Rakefile @@ -296,7 +296,6 @@ namespace :test do |ns| test "array/intersection.t" test "array/join.t" test "array/mathop.t" - test "array/nitems.t" test "array/pop.t" test "array/push.t" test "array/reject.t" @@ -311,7 +310,7 @@ namespace :test do |ns| test "array/warray.t" desc "Run tests on Array." - task :all => [:array, :assign, :at, :clear, :collect, :compact, :concat, :delete, :empty, :equals, :fetch, :fill, :first, :flatten, :grep, :include, :index, :insert, :intersection, :join, :mathop, :nitems, :pop, :push, :reject, :replace, :reverse, :shift, :slice, :sort, :to_s, :uniq, :values_at, :warray] + task :all => [:array, :assign, :at, :clear, :collect, :compact, :concat, :delete, :empty, :equals, :fetch, :fill, :first, :flatten, :grep, :include, :index, :insert, :intersection, :join, :mathop, :pop, :push, :reject, :replace, :reverse, :shift, :slice, :sort, :to_s, :uniq, :values_at, :warray] end namespace :file do diff --git a/src/classes/Array.pir b/src/classes/Array.pir index 62d688f..2d34555 100644 --- a/src/classes/Array.pir +++ b/src/classes/Array.pir @@ -1640,22 +1640,6 @@ The zip operator. # TODO: pass warning .end -.sub 'nitems' :method - .local int count - .local pmc it - count = 0 - it = iter self - iter_loop: - unless it goto done - $P0 = shift it - $I0 = isa $P0, "NilClass" - if $I0 goto iter_loop - inc count - goto iter_loop - done: - .return ( count ) -.end - .sub '_cmp' :vtable('cmp') :method .param pmc other .local int i, len, result diff --git a/t/array/nitems.t b/t/array/nitems.t deleted file mode 100644 index 21dd42d..0000000 --- a/t/array/nitems.t +++ /dev/null @@ -1,16 +0,0 @@ -require 'Test' -include Test -plan 4 - -a = [ ] -is a.nitems(), 0, 'nitems, no items' - -a = [ 1, 2, 3, 4 ] -is a.nitems(), 4, 'nitems, 4 non-nil items' - -a = [ 1, 2, 3, nil ] -is a.nitems(), 3, 'nitems, 3 non-nil items, 1 nil' - -a = [ nil, nil, nil, nil ] -is a.nitems(), 0, 'nitems, 4 nil items' - From a2b5f4dcbf6db1d1a1bdd88a1301e745aea0ad79 Mon Sep 17 00:00:00 2001 From: Danius Michaelides Date: Sun, 23 Aug 2009 22:59:15 +0800 Subject: [PATCH 20/32] Implement Array#count() - new to ruby 1.9. Signed-off-by: Ted Reed --- Rakefile | 3 ++- src/classes/Array.pir | 44 +++++++++++++++++++++++++++++++++++++++++++ t/array/count.t | 14 ++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 t/array/count.t diff --git a/Rakefile b/Rakefile index a72e015..a3c6a1c 100644 --- a/Rakefile +++ b/Rakefile @@ -282,6 +282,7 @@ namespace :test do |ns| 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" @@ -310,7 +311,7 @@ namespace :test do |ns| test "array/warray.t" desc "Run tests on Array." - task :all => [:array, :assign, :at, :clear, :collect, :compact, :concat, :delete, :empty, :equals, :fetch, :fill, :first, :flatten, :grep, :include, :index, :insert, :intersection, :join, :mathop, :pop, :push, :reject, :replace, :reverse, :shift, :slice, :sort, :to_s, :uniq, :values_at, :warray] + 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, :shift, :slice, :sort, :to_s, :uniq, :values_at, :warray] end namespace :file do diff --git a/src/classes/Array.pir b/src/classes/Array.pir index 2d34555..d4a9203 100644 --- a/src/classes/Array.pir +++ b/src/classes/Array.pir @@ -1640,6 +1640,50 @@ The zip operator. # TODO: pass warning .end +.sub 'count' :method + .param pmc obj :optional + .param int obj_flag :opt_flag + .param pmc block :optional :named("!BLOCK") + .param int block_flag :opt_flag + .local pmc it + .local pmc val + .local int count + + if obj_flag goto has_object + if block_flag goto has_block + + count=elements self + .return(count) + + has_block: + count = 0 + it = iter self + iter_loop: + unless it goto block_done + val = shift it + $P0=block(val) + unless $P0 goto iter_loop + inc count + goto iter_loop + block_done: + .return(count) + + has_object: + # TODO: raise warning if block given + count = 0 + it = iter self + iter_loop2: + unless it goto block_done2 + val = shift it + eq val, obj, iter_match + goto iter_loop2 + iter_match: + inc count + goto iter_loop2 + block_done2: + .return(count) +.end + .sub '_cmp' :vtable('cmp') :method .param pmc other .local int i, len, result diff --git a/t/array/count.t b/t/array/count.t new file mode 100644 index 0000000..2966fa5 --- /dev/null +++ b/t/array/count.t @@ -0,0 +1,14 @@ +require 'Test' +include Test +plan 4 + +a = [ ] +is a.count(), 0, 'count, no items' + +a = [ 1, 2, 3, 4 ] +is a.count(), 4, 'count, no args ' + +is a.count(2), 1, 'count, obj arg' + +is a.count{|x| x>2 }, 2, 'count, block arg' + From f33b4944e160024765ec2d3e37eb840925e59170 Mon Sep 17 00:00:00 2001 From: Danius Michaelides Date: Sun, 23 Aug 2009 23:18:56 +0800 Subject: [PATCH 21/32] Implement Array#select. Signed-off-by: Ted Reed --- Rakefile | 3 ++- src/classes/Array.pir | 21 +++++++++++++++++++++ t/array/select.t | 11 +++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 t/array/select.t diff --git a/Rakefile b/Rakefile index a3c6a1c..ae54376 100644 --- a/Rakefile +++ b/Rakefile @@ -302,6 +302,7 @@ namespace :test do |ns| 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" @@ -311,7 +312,7 @@ namespace :test do |ns| 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, :shift, :slice, :sort, :to_s, :uniq, :values_at, :warray] + 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 diff --git a/src/classes/Array.pir b/src/classes/Array.pir index d4a9203..5ddb52b 100644 --- a/src/classes/Array.pir +++ b/src/classes/Array.pir @@ -284,6 +284,27 @@ Return a sorted copy of the list .return ($P0) .end +.sub 'select' :method + .param pmc block :named('!BLOCK') + .local pmc uarray, val + + uarray = new 'CardinalArray' + $P0 = iter self + + loop: + unless $P0 goto done + + $P1 = shift $P0 + $P2 = block($P1) + unless $P2 goto loop + + uarray.'push'($P1) + goto loop + + done: + .return (uarray) +.end + .sub reject :method .param pmc block :named("!BLOCK") .local pmc uarray, val diff --git a/t/array/select.t b/t/array/select.t new file mode 100644 index 0000000..a610c37 --- /dev/null +++ b/t/array/select.t @@ -0,0 +1,11 @@ +require 'Test' +include Test +plan 2 + +a = [ "a", "b", "c", "d", "e", "f" ] +b = a.select {|v| v == "a"} +is b, [ "a" ] + +a = [ 0, 1, 2, 3, 4, 5 ] +b = a.select {|v| v % 2 == 1} +is b, [ 1, 3, 5 ] From eb932f564df452f23add8edc9274a1910d569db4 Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Tue, 25 Aug 2009 00:17:11 -0700 Subject: [PATCH 22/32] Add report target that generates a TAP archive. --- Rakefile | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Rakefile b/Rakefile index ae54376..4cd1d72 100644 --- a/Rakefile +++ b/Rakefile @@ -8,8 +8,10 @@ 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') DEBUG = ENV['debug'] || false ALTERNATIVE_RUBY = ENV['test_with'] || false @@ -33,6 +35,8 @@ $issue_lacks = 0 $i_l_files = [] $pl = false $start = Time.now +$meta = Hash.new +$report = false def clean? return false if $nok > $expected_failures @@ -100,11 +104,25 @@ def test(file, name="") 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 @@ -112,6 +130,7 @@ def run_test(file,name="") plan = "x" end puts plan if DEBUG + report_file.write(plan) if $report if plan =~ /^1\.\.([0-9]+)/ tests = $1.to_i $tests += tests @@ -123,6 +142,7 @@ def run_test(file,name="") t.readlines.each do |line| test += 1 puts line if DEBUG + report_file.write(line) if line =~ /^ok #{test}/ ok += 1 if line =~ /TODO/ @@ -169,10 +189,27 @@ def run_test(file,name="") result = "Complete failure... no plan given" $failures += 1 end + report_file.close if $report puts "Running #{name} #{result}" end end +desc "Produce a TAP archive" +task :report 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 + 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 "Determine configuration information" task :config => "build.yaml" do require 'yaml' From 7ccf0ae44184250d2b17a2350eabdf08c1d7d523 Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Tue, 25 Aug 2009 01:14:56 -0700 Subject: [PATCH 23/32] Adds the architecture, branch, and platform extra_properties to the TAP archive. --- Rakefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Rakefile b/Rakefile index 4cd1d72..f6d2245 100644 --- a/Rakefile +++ b/Rakefile @@ -201,6 +201,11 @@ task :report do $meta['file_order'] = Array.new Task['test:all'].invoke $meta['stop_time'] = Time.now.to_i + $meta['extra_properties'] = { + 'Architecture' => `uname -p`.chomp, + 'Platform' => `uname -s`.chomp, + 'Branch' => `git status`.split('\n')[0].split(' ')[3] + } require 'yaml' File.open('report/meta.yml','w') do |f| YAML::dump($meta, f) From 3be9b00320a97e170b27390359ed3ac34d2cb246 Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Tue, 25 Aug 2009 01:24:43 -0700 Subject: [PATCH 24/32] Add extra_properties for submitter and commit (in lieu of version) --- Rakefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index f6d2245..54de41f 100644 --- a/Rakefile +++ b/Rakefile @@ -201,10 +201,15 @@ task :report do $meta['file_order'] = Array.new Task['test:all'].invoke $meta['stop_time'] = Time.now.to_i + submitter = ENV['SMOLDER_SUBMITTER'] + submitter = "#{`whoami`.chomp}@#{`hostname`.chomp}" if submitter = '' + commit = `git log -1 --format=%H`.chomp $meta['extra_properties'] = { 'Architecture' => `uname -p`.chomp, 'Platform' => `uname -s`.chomp, - 'Branch' => `git status`.split('\n')[0].split(' ')[3] + 'Branch' => `git status`.split('\n')[0].split(' ')[3], + 'Submitter' => submitter, + 'Commit' => commit } require 'yaml' File.open('report/meta.yml','w') do |f| From 5e1d506f6257f94af7dbce55407207b0cf5e8840 Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Tue, 25 Aug 2009 01:43:28 -0700 Subject: [PATCH 25/32] Provide method for overriding parrot_config detection via environment variable. --- Rakefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 54de41f..19c5ab9 100644 --- a/Rakefile +++ b/Rakefile @@ -15,6 +15,7 @@ CLOBBER.include('report.tar.gz') DEBUG = ENV['debug'] || false ALTERNATIVE_RUBY = ENV['test_with'] || false +PARROT_CONFIG = ENV["PARROT_CONFIG"] || 'parrot_config' CONFIG = {} $tests = 0 $test_files = 0 @@ -236,10 +237,11 @@ end file "build.yaml" do require 'yaml' config = {} - IO.popen("parrot_config build_dir", "r") do |p| + IO.popen("#{PARROT_CONFIG} build_dir", "r") do |p| config[:build_dir] = p.readline.chomp end - puts "Detected parrot_config reports that build_dir is #{config[:build_dir]}." + print PARROT_CONFIG == 'parrot_config' ? "Detected " : "Provided " + puts "parrot_config reports that build_dir is #{config[:build_dir]}." config[:parrot] = config[:build_dir] + "/parrot" config[:perl6grammar] = config[:build_dir] + "/runtime/parrot/library/PGE/Perl6Grammar.pbc" From ad14323e380a29c0b4c4e0167c862d272d32ef38 Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Tue, 25 Aug 2009 01:51:28 -0700 Subject: [PATCH 26/32] Some code for the report target wasn't properly guarded. treed-- --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 19c5ab9..fe2fd6c 100644 --- a/Rakefile +++ b/Rakefile @@ -143,7 +143,7 @@ def run_test(file,name="") t.readlines.each do |line| test += 1 puts line if DEBUG - report_file.write(line) + report_file.write(line) if $report if line =~ /^ok #{test}/ ok += 1 if line =~ /TODO/ From 8d2377f181159c80b67c2987a6bcc0b35a0d3299 Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Wed, 26 Aug 2009 20:40:28 -0700 Subject: [PATCH 27/32] Fix the Rakefile so that test suites will still complete if individual files bail out. --- Rakefile | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index fe2fd6c..61517cf 100644 --- a/Rakefile +++ b/Rakefile @@ -34,6 +34,8 @@ $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 @@ -46,6 +48,7 @@ def clean? 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 @@ -96,7 +99,13 @@ def test(file, name="") unless File.exists?('cardinal.pbc') Task['cardinal.pbc'].invoke end - parrot("t/#{file}", "t/#{pir_file}", "cardinal.pbc", "pir") + 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| @@ -187,7 +196,13 @@ def run_test(file,name="") $toomany_files += [file] end else - result = "Complete failure... no plan given" + 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 @@ -502,6 +517,14 @@ namespace :test do |ns| 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 From 870ad48af64d5127a1ad189167c5a65c3bf763cd Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Tue, 1 Sep 2009 23:48:47 -0700 Subject: [PATCH 28/32] Add a smolder target to the Rakefile to submit report.tar.gz to the appropriate website. --- Rakefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Rakefile b/Rakefile index 61517cf..6013d5c 100644 --- a/Rakefile +++ b/Rakefile @@ -236,6 +236,12 @@ task :report do chdir '..' end +desc "Submit a smolder report." +task :smolder => :report do + props = $meta['extra_properties'] + sh "curl -F \"architecture=#{props['Architecture']}\" -F \"platform=#{props['Platform']}\" -F \"revision=#{props['Commit']}\" -F \"report_file=@report.tar.gz\" http://smolder.plusthree.com/app/public_projects/process_add_report/16" +end + desc "Determine configuration information" task :config => "build.yaml" do require 'yaml' From 7d77922e2403b4720986ceebea8659cf9e760153 Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Wed, 2 Sep 2009 00:18:15 -0700 Subject: [PATCH 29/32] Refactor the Rakefile a little. --- Rakefile | 84 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/Rakefile b/Rakefile index 6013d5c..462a427 100644 --- a/Rakefile +++ b/Rakefile @@ -16,7 +16,7 @@ CLOBBER.include('report.tar.gz') DEBUG = ENV['debug'] || false ALTERNATIVE_RUBY = ENV['test_with'] || false PARROT_CONFIG = ENV["PARROT_CONFIG"] || 'parrot_config' -CONFIG = {} +$config = {} $tests = 0 $test_files = 0 $ok = 0 @@ -71,12 +71,12 @@ 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}" + 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" + sh "#{$config[:pbc_to_exe]} cardinal.pbc" end def test(file, name="") @@ -131,7 +131,7 @@ def run_test(file,name="") puts file if DEBUG name = file if name == "" $test_files += 1 - command = ALTERNATIVE_RUBY || CONFIG[:parrot] + command = ALTERNATIVE_RUBY || $config[:parrot] report_file = get_report_file(file) if $report IO.popen("#{command} t/#{file}", "r") do |t| begin @@ -211,21 +211,18 @@ def run_test(file,name="") end desc "Produce a TAP archive" -task :report do +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 - submitter = ENV['SMOLDER_SUBMITTER'] - submitter = "#{`whoami`.chomp}@#{`hostname`.chomp}" if submitter = '' - commit = `git log -1 --format=%H`.chomp $meta['extra_properties'] = { - 'Architecture' => `uname -p`.chomp, - 'Platform' => `uname -s`.chomp, - 'Branch' => `git status`.split('\n')[0].split(' ')[3], - 'Submitter' => submitter, - 'Commit' => commit + 'Architecture' => get_arch, + 'Platform' => get_platform, + 'Branch' => get_branch, + 'Submitter' => get_submitter, + 'Commit' => get_commit } require 'yaml' File.open('report/meta.yml','w') do |f| @@ -237,40 +234,61 @@ task :report do end desc "Submit a smolder report." -task :smolder => :report do - props = $meta['extra_properties'] - sh "curl -F \"architecture=#{props['Architecture']}\" -F \"platform=#{props['Platform']}\" -F \"revision=#{props['Commit']}\" -F \"report_file=@report.tar.gz\" http://smolder.plusthree.com/app/public_projects/process_add_report/16" +task :smolder => "report.tar.gz" do + sh "curl -F \"architecture=#{get_arch}\" -F \"platform=#{get_platform}\" -F \"revision=#{get_commit}\" -F \"report_file=@report.tar.gz\" http://smolder.plusthree.com/app/public_projects/process_add_report/16" end desc "Determine configuration information" task :config => "build.yaml" do require 'yaml' File.open("build.yaml","r") do |f| - CONFIG.update(YAML.load(f)) + $config.update(YAML.load(f)) end - return false unless File.exist?(CONFIG[:parrot]) - return false unless File.exist?(CONFIG[:perl6grammar]) - return false unless File.exist?(CONFIG[:nqp]) - return false unless File.exist?(CONFIG[:pct]) - return false unless File.exist?(CONFIG[:pbc_to_exe]) + return false unless File.exist?($config[:parrot]) + return false unless File.exist?($config[:perl6grammar]) + return false unless File.exist?($config[:nqp]) + return false unless File.exist?($config[:pct]) + return false unless File.exist?($config[:pbc_to_exe]) +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 == '' +end + +def get_commit + `git log -1 --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 + $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]}." + puts "parrot_config reports that build_dir is #{$config[:build_dir]}." + + $config[:parrot] = $config[:build_dir] + "/parrot" + $config[:perl6grammar] = $config[:build_dir] + "/runtime/parrot/library/PGE/Perl6Grammar.pbc" + $config[:nqp] = $config[:build_dir] + "/compilers/nqp/nqp.pbc" + $config[:pct] = $config[:build_dir] + "/runtime/parrot/library/PCT.pbc" + $config[:pbc_to_exe] = $config[:build_dir] + "/pbc_to_exe" - config[:parrot] = config[:build_dir] + "/parrot" - config[:perl6grammar] = config[:build_dir] + "/runtime/parrot/library/PGE/Perl6Grammar.pbc" - config[:nqp] = config[:build_dir] + "/compilers/nqp/nqp.pbc" - config[:pct] = config[:build_dir] + "/runtime/parrot/library/PCT.pbc" - config[:pbc_to_exe] = config[:build_dir] + "/pbc_to_exe" File.open("build.yaml","w") do |f| - YAML.dump(config, f) + YAML.dump($config, f) end end @@ -290,11 +308,11 @@ file "cardinal.pbc" => sources do end file "src/gen_grammar.pir" => [:config, 'src/parser/grammar.pg'] do - parrot("src/parser/grammar.pg", "src/gen_grammar.pir", CONFIG[:perl6grammar]) + 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') + 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/Integer.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") From c25a9e2491295d970795a59ce1789814dc182fca Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Mon, 14 Sep 2009 20:15:44 -0700 Subject: [PATCH 30/32] Add Parrot Revision to smolder report, and adjust method for getting commit id. (jdv79++) --- Rakefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 462a427..f189847 100644 --- a/Rakefile +++ b/Rakefile @@ -224,6 +224,11 @@ task "report.tar.gz" do 'Submitter' => get_submitter, 'Commit' => get_commit } + + IO.popen("#{PARROT_CONFIG} revision", "r") do |p| + $meta['Parrot Revision'] = p.readline.chomp.to_i + end + require 'yaml' File.open('report/meta.yml','w') do |f| YAML::dump($meta, f) @@ -269,7 +274,7 @@ def get_submitter end def get_commit - `git log -1 --format=%H`.chomp + `git log -1 --pretty=format:%H`.chomp end file "build.yaml" do From 46b861fe0ccf90d425b58b72c5d1a09db69d7629 Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Tue, 15 Sep 2009 08:10:01 -0700 Subject: [PATCH 31/32] Move the Parrot Revision to its proper place. (jdv79++) --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index f189847..0925676 100644 --- a/Rakefile +++ b/Rakefile @@ -226,7 +226,7 @@ task "report.tar.gz" do } IO.popen("#{PARROT_CONFIG} revision", "r") do |p| - $meta['Parrot Revision'] = p.readline.chomp.to_i + $meta['extra_properties']['Parrot Revision'] = p.readline.chomp.to_i end require 'yaml' From e1037c8c03323e991860b935c71d5e73dbefae32 Mon Sep 17 00:00:00 2001 From: Ted Reed Date: Wed, 23 Sep 2009 08:47:31 -0700 Subject: [PATCH 32/32] Ensure that get_submitter always returns something. (jdv79++) --- Rakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Rakefile b/Rakefile index 0925676..5f2f199 100644 --- a/Rakefile +++ b/Rakefile @@ -271,6 +271,7 @@ 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