Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 148 lines (127 sloc) 4.573 kB
bb4d189 @sstephenson prototype: Reorganize the source tree.
authored
1 require 'rake'
2 require 'rake/packagetask'
3
52a781a @tobie Switch to UnittestJS.
tobie authored
4 PROTOTYPE_ROOT = File.expand_path(File.dirname(__FILE__))
5 PROTOTYPE_SRC_DIR = File.join(PROTOTYPE_ROOT, 'src')
6 PROTOTYPE_DIST_DIR = File.join(PROTOTYPE_ROOT, 'dist')
7 PROTOTYPE_PKG_DIR = File.join(PROTOTYPE_ROOT, 'pkg')
8 PROTOTYPE_TEST_DIR = File.join(PROTOTYPE_ROOT, 'test')
9 PROTOTYPE_TEST_UNIT_DIR = File.join(PROTOTYPE_TEST_DIR, 'unit')
10 PROTOTYPE_TMP_DIR = File.join(PROTOTYPE_TEST_UNIT_DIR, 'tmp')
11 PROTOTYPE_VERSION = '1.6.0.3'
bb4d189 @sstephenson prototype: Reorganize the source tree.
authored
12
87ce153 @tobie prototype: Complete rewrite of the deprecation helper.
tobie authored
13 task :default => [:dist, :dist_helper, :package, :clean_package_source]
bb4d189 @sstephenson prototype: Reorganize the source tree.
authored
14
cf5d180 @tobie refactored unit tests quite a bit. Added JS and CSS fixtures.
tobie authored
15 desc "Builds the distribution."
bb4d189 @sstephenson prototype: Reorganize the source tree.
authored
16 task :dist do
17 $:.unshift File.join(PROTOTYPE_ROOT, 'lib')
18 require 'protodoc'
19
20 Dir.chdir(PROTOTYPE_SRC_DIR) do
21 File.open(File.join(PROTOTYPE_DIST_DIR, 'prototype.js'), 'w+') do |dist|
22 dist << Protodoc::Preprocessor.new('prototype.js')
23 end
24 end
25 end
26
cf5d180 @tobie refactored unit tests quite a bit. Added JS and CSS fixtures.
tobie authored
27 desc "Builds the updating helper."
87ce153 @tobie prototype: Complete rewrite of the deprecation helper.
tobie authored
28 task :dist_helper do
29 $:.unshift File.join(PROTOTYPE_ROOT, 'lib')
30 require 'protodoc'
31
32 Dir.chdir(File.join(PROTOTYPE_ROOT, 'ext', 'update_helper')) do
33 File.open(File.join(PROTOTYPE_DIST_DIR, 'prototype_update_helper.js'), 'w+') do |dist|
34 dist << Protodoc::Preprocessor.new('prototype_update_helper.js')
35 end
36 end
37 end
38
bb4d189 @sstephenson prototype: Reorganize the source tree.
authored
39 Rake::PackageTask.new('prototype', PROTOTYPE_VERSION) do |package|
40 package.need_tar_gz = true
41 package.package_dir = PROTOTYPE_PKG_DIR
42 package.package_files.include(
43 '[A-Z]*',
44 'dist/prototype.js',
45 'lib/**',
46 'src/**',
47 'test/**'
48 )
49 end
50
52a781a @tobie Switch to UnittestJS.
tobie authored
51 task :clean_package_source do
52 rm_rf File.join(PROTOTYPE_PKG_DIR, "prototype-#{PROTOTYPE_VERSION}")
53 end
bb4d189 @sstephenson prototype: Reorganize the source tree.
authored
54
52a781a @tobie Switch to UnittestJS.
tobie authored
55 task :test => ['test:build', 'test:run']
56 namespace :test do
57 desc 'Runs all the JavaScript unit tests and collects the results'
58 task :run => [:require] do
59 testcases = ENV['TESTCASES']
60 browsers_to_test = ENV['BROWSERS'] && ENV['BROWSERS'].split(',')
61 tests_to_run = ENV['TESTS'] && ENV['TESTS'].split(',')
62 runner = UnittestJS::WEBrickRunner::Runner.new(:test_dir => PROTOTYPE_TMP_DIR)
63
64 Dir[File.join(PROTOTYPE_TMP_DIR, '*_test.html')].each do |file|
65 file = File.basename(file)
66 test = file.sub('_test.html', '')
67 unless tests_to_run && !tests_to_run.include?(test)
68 runner.add_test(file, testcases)
69 end
70 end
71
72 UnittestJS::Browser::SUPPORTED.each do |browser|
73 unless browsers_to_test && !browsers_to_test.include?(browser)
74 runner.add_browser(browser.to_sym)
75 end
76 end
77
78 trap('INT') { runner.teardown; exit }
79 runner.run
80 end
bb4d189 @sstephenson prototype: Reorganize the source tree.
authored
81
52a781a @tobie Switch to UnittestJS.
tobie authored
82 task :build => [:clean, :dist] do
83 builder = UnittestJS::Builder::SuiteBuilder.new({
84 :input_dir => PROTOTYPE_TEST_UNIT_DIR,
85 :assets_dir => PROTOTYPE_DIST_DIR
86 })
87 selected_tests = (ENV['TESTS'] || '').split(',')
88 builder.collect(*selected_tests)
89 builder.render
90 end
ba6934e @tobie Make Rake auto-generate test/unit/temp directory if it is missing.
tobie authored
91
52a781a @tobie Switch to UnittestJS.
tobie authored
92 task :clean => [:require] do
93 UnittestJS::Builder.empty_dir!(PROTOTYPE_TMP_DIR)
bb4d189 @sstephenson prototype: Reorganize the source tree.
authored
94 end
95
52a781a @tobie Switch to UnittestJS.
tobie authored
96 task :require do
97 lib = 'vendor/unittest_js/lib/unittest_js'
98 unless File.exists?(lib)
99 puts "\nYou'll need UnittestJS to run the tests. Just run:\n\n"
100 puts " $ git submodule init"
101 puts " $ git submodule update"
102 puts "\nand you should be all set.\n\n"
103 end
104 require lib
bb4d189 @sstephenson prototype: Reorganize the source tree.
authored
105 end
106 end
41ef42e @tobie Unit test lib reorganizing.
tobie authored
107
52a781a @tobie Switch to UnittestJS.
tobie authored
108 task :test_units do
109 puts '"rake test_units" is deprecated. Please use "rake test" instead.'
41ef42e @tobie Unit test lib reorganizing.
tobie authored
110 end
111
52a781a @tobie Switch to UnittestJS.
tobie authored
112 task :build_unit_tests do
113 puts '"rake test_units" is deprecated. Please use "rake test:build" instead.'
41ef42e @tobie Unit test lib reorganizing.
tobie authored
114 end
115
116 task :clean_tmp do
52a781a @tobie Switch to UnittestJS.
tobie authored
117 puts '"rake clean_tmp" is deprecated. Please use "rake test:clean" instead.'
41ef42e @tobie Unit test lib reorganizing.
tobie authored
118 end
99f74b5 @tobie Add caja_builder for optional cajoled tests.
tobie authored
119
120 namespace :caja do
121 task :test => ['test:build', 'test:run']
122
123 namespace :test do
124 task :run => ['rake:test:run']
125
126 task :build => [:require, 'rake:test:clean', :dist] do
127 builder = UnittestJS::CajaBuilder::SuiteBuilder.new({
128 :input_dir => PROTOTYPE_TEST_UNIT_DIR,
129 :assets_dir => PROTOTYPE_DIST_DIR,
130 :whitelist_dir => File.join(PROTOTYPE_TEST_DIR, 'unit', 'caja_whitelists'),
131 :html_attrib_schema => 'html_attrib.json'
132 })
133 selected_tests = (ENV['TESTS'] || '').split(',')
134 builder.collect(*selected_tests)
135 builder.render
136 end
137 end
138 task :require => ['rake:test:require'] do
139 lib = 'vendor/caja_builder/lib/caja_builder'
140 unless File.exists?(lib)
141 puts "\nYou'll need UnittestJS to run the tests. Just run:\n\n"
142 puts " $ git submodule init"
143 puts " $ git submodule update"
144 puts "\nand you should be all set.\n\n"
145 end
146 require lib
147 end
148 end
Something went wrong with that request. Please try again.