Permalink
Browse files

Add CommonJS as submodule and a `spec` rake task to run Module 1.0 sp…

…ecs using SpiderMonkey f:1,5
  • Loading branch information...
1 parent 0ec2200 commit 54d5afa8e8b02ad00914f22ff46cd63af023d698 @samleb samleb committed Mar 5, 2010
Showing with 32 additions and 0 deletions.
  1. +3 −0 .gitmodules
  2. +28 −0 Rakefile
  3. +1 −0 vendor/commonjs
View
@@ -0,0 +1,3 @@
+[submodule "vendor/commonjs"]
+ path = vendor/commonjs
+ url = git://github.com/commonjs/commonjs.git
View
@@ -2,13 +2,41 @@ require 'rubygems'
require 'rake'
require 'lib/modulr'
+COMMONJS_SPEC_DIR = File.join('vendor', 'commonjs', 'tests', 'modules', '1.0')
+
desc "Concatenate example file"
task :build_example do
File.open(File.join('output', 'example.js'), 'w') do |f|
f << Modulr.ize(File.join('example', 'program.js'))
end
end
+desc "Run CommonJS Module 1.0 specs"
+task :spec do
+ specs = ENV["SPECS"] || "**"
+
+ FileList["#{COMMONJS_SPEC_DIR}/{#{specs}}/program.js"].each do |spec|
+ dir = File.dirname(spec)
+ output = File.join(dir, 'output.js')
+ system = File.join(dir, 'system.js')
+ FileUtils.touch(system)
+ begin
+ puts File.basename(dir).center(80, "_")
+ File.open(output, 'w') do |f|
+ f << Modulr.ize(spec)
+ end
+ system("js -f #{output}")
+ rescue => e
+ phase = e.is_a?(Modulr::ModulrError) ? "building" : "running"
+ puts "ERROR while #{phase} (#{e.class}):"
+ puts e.message
+ ensure
+ FileUtils.rm(output)
+ FileUtils.rm(system)
+ end
+ end
+end
+
begin
require "jeweler"
Jeweler::Tasks.new do |gemspec|
Submodule commonjs added at 9652a0

0 comments on commit 54d5afa

Please sign in to comment.