Refactor of standalone build tasks; Better templating of the core runner.html and the example SpecRunner.html
This commit is contained in:
@@ -2,26 +2,53 @@
|
|||||||
"http://www.w3.org/TR/html4/loose.dtd">
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Jasmine Test Runner</title>
|
<title>Jasmine Spec Runner</title>
|
||||||
<link rel="stylesheet" type="text/css" href="lib/jasmine-##JASMINE_VERSION##/jasmine.css">
|
|
||||||
<script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine.js"></script>
|
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.1.0/jasmine_favicon.png">
|
||||||
<script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine-html.js"></script>
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.1.0/jasmine.css">
|
||||||
|
<script type="text/javascript" src="lib/jasmine-1.1.0/jasmine.js"></script>
|
||||||
|
<script type="text/javascript" src="lib/jasmine-1.1.0/jasmine-html.js"></script>
|
||||||
|
|
||||||
<!-- include source files here... -->
|
<!-- include source files here... -->
|
||||||
<script type="text/javascript" src="src/Player.js"></script>
|
|
||||||
<script type="text/javascript" src="src/Song.js"></script>
|
|
||||||
|
|
||||||
<!-- include spec files here... -->
|
|
||||||
<script type="text/javascript" src="spec/SpecHelper.js"></script>
|
<script type="text/javascript" src="spec/SpecHelper.js"></script>
|
||||||
<script type="text/javascript" src="spec/PlayerSpec.js"></script>
|
<script type="text/javascript" src="spec/PlayerSpec.js"></script>
|
||||||
|
|
||||||
</head>
|
<!-- include spec files here... -->
|
||||||
<body>
|
<script type="text/javascript" src="src/Player.js"></script>
|
||||||
<div id="REMOVE_THIS_LINE_FROM_BUILD"><p>You must be trying to look at examples in the Jasmine source tree.</p><p>Please download a distribution version of Jasmine at <a href="http://pivotal.github.com/jasmine/">http://pivotal.github.com/jasmine/</a>.</p></div>
|
<script type="text/javascript" src="src/Song.js"></script>
|
||||||
<script type="text/javascript">
|
|
||||||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
|
||||||
jasmine.getEnv().execute();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
(function() {
|
||||||
|
var jasmineEnv = jasmine.getEnv();
|
||||||
|
jasmineEnv.updateInterval = 1000;
|
||||||
|
|
||||||
|
var trivialReporter = new jasmine.TrivialReporter();
|
||||||
|
|
||||||
|
jasmineEnv.addReporter(trivialReporter);
|
||||||
|
|
||||||
|
jasmineEnv.specFilter = function(spec) {
|
||||||
|
return trivialReporter.specFilter(spec);
|
||||||
|
};
|
||||||
|
|
||||||
|
var currentWindowOnload = window.onload;
|
||||||
|
|
||||||
|
window.onload = function() {
|
||||||
|
if (currentWindowOnload) {
|
||||||
|
currentWindowOnload();
|
||||||
|
}
|
||||||
|
execJasmine();
|
||||||
|
};
|
||||||
|
|
||||||
|
function execJasmine() {
|
||||||
|
jasmineEnv.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -2467,5 +2467,5 @@ jasmine.version_= {
|
|||||||
"major": 1,
|
"major": 1,
|
||||||
"minor": 1,
|
"minor": 1,
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"revision": 1308065344
|
"revision": 1308154429
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,18 +2,23 @@
|
|||||||
"http://www.w3.org/TR/html4/loose.dtd">
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Jasmine Test Runner</title>
|
<title>Jasmine Spec Runner: Jasmine Core</title>
|
||||||
|
|
||||||
|
<link rel="shortcut icon" type="image/png" href="../images/jasmine_favicon.png">
|
||||||
|
|
||||||
|
<link href="../lib/jasmine.css" rel="stylesheet"/>
|
||||||
|
<script type="text/javascript" src="../lib/jasmine.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// yes, really keep this here to keep us honest, but only for jasmine's own runner! [xw]
|
// yes, really keep this here to keep us honest, but only for jasmine's own runner! [xw]
|
||||||
undefined = "diz be undefined yo";
|
undefined = "diz be undefined yo";
|
||||||
</script>
|
</script>
|
||||||
<link rel="shortcut icon" type="image/png" href="../images/jasmine_favicon.png">
|
|
||||||
<script type="text/javascript" src="../lib/jasmine.js"></script>
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- include source files here... -->
|
||||||
<script type="text/javascript" src="../src/html/TrivialReporter.js"></script>
|
<script type="text/javascript" src="../src/html/TrivialReporter.js"></script>
|
||||||
<script type="text/javascript" src="../src/console/TrivialConsoleReporter.js"></script>
|
<script type="text/javascript" src="../src/console/TrivialConsoleReporter.js"></script>
|
||||||
|
|
||||||
|
<!-- include spec files here... -->
|
||||||
<script type="text/javascript" src="../spec/core/BaseSpec.js"></script>
|
<script type="text/javascript" src="../spec/core/BaseSpec.js"></script>
|
||||||
<script type="text/javascript" src="../spec/core/CustomMatchersSpec.js"></script>
|
<script type="text/javascript" src="../spec/core/CustomMatchersSpec.js"></script>
|
||||||
<script type="text/javascript" src="../spec/core/EnvSpec.js"></script>
|
<script type="text/javascript" src="../spec/core/EnvSpec.js"></script>
|
||||||
@@ -51,13 +56,22 @@
|
|||||||
return trivialReporter.specFilter(spec);
|
return trivialReporter.specFilter(spec);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var currentWindowOnload = window.onload;
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
jasmineEnv.execute();
|
if (currentWindowOnload) {
|
||||||
|
currentWindowOnload();
|
||||||
|
}
|
||||||
|
execJasmine();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function execJasmine() {
|
||||||
|
jasmineEnv.execute();
|
||||||
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<link href="../src/html/jasmine.css" rel="stylesheet"/>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -2,17 +2,15 @@
|
|||||||
"http://www.w3.org/TR/html4/loose.dtd">
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Jasmine Test Runner</title>
|
<title><%= title %></title>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<%= favicon %>
|
||||||
// yes, really keep this here to keep us honest, but only for jasmine's own runner! [xw]
|
<%= jasmine_tags %>
|
||||||
undefined = "diz be undefined yo";
|
|
||||||
</script>
|
|
||||||
<link rel="shortcut icon" type="image/png" href="../images/jasmine_favicon.png">
|
|
||||||
<script type="text/javascript" src="../lib/jasmine.js"></script>
|
|
||||||
|
|
||||||
|
<!-- include source files here... -->
|
||||||
<%= source_tags %>
|
<%= source_tags %>
|
||||||
|
|
||||||
|
<!-- include spec files here... -->
|
||||||
<%= spec_file_tags %>
|
<%= spec_file_tags %>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@@ -28,13 +26,22 @@
|
|||||||
return trivialReporter.specFilter(spec);
|
return trivialReporter.specFilter(spec);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var currentWindowOnload = window.onload;
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
jasmineEnv.execute();
|
if (currentWindowOnload) {
|
||||||
|
currentWindowOnload();
|
||||||
|
}
|
||||||
|
execJasmine();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function execJasmine() {
|
||||||
|
jasmineEnv.execute();
|
||||||
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<link href="../src/html/jasmine.css" rel="stylesheet"/>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
3
src/templates/example_project_jasmine_tags.html.erb
Normal file
3
src/templates/example_project_jasmine_tags.html.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<link rel="stylesheet" type="text/css" href="lib/jasmine-<%= jasmine_version %>/jasmine.css">
|
||||||
|
<script type="text/javascript" src="lib/jasmine-<%= jasmine_version %>/jasmine.js"></script>
|
||||||
|
<script type="text/javascript" src="lib/jasmine-<%= jasmine_version %>/jasmine-html.js"></script>
|
||||||
@@ -2,5 +2,5 @@ jasmine.version_= {
|
|||||||
"major": 1,
|
"major": 1,
|
||||||
"minor": 1,
|
"minor": 1,
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"revision": 1308065344
|
"revision": 1308154429
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ desc "Build core jasmine.js"
|
|||||||
task :build_dist => [:lint, :write_version_file] do
|
task :build_dist => [:lint, :write_version_file] do
|
||||||
puts 'Building Jasmine distribution from source'
|
puts 'Building Jasmine distribution from source'
|
||||||
|
|
||||||
require 'pp'
|
|
||||||
concat_into('lib/jasmine.js') { core_sources + version_source_file }
|
concat_into('lib/jasmine.js') { core_sources + version_source_file }
|
||||||
concat_into('lib/jasmine-html.js') { html_sources }
|
concat_into('lib/jasmine-html.js') { html_sources }
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,43 @@
|
|||||||
require 'ostruct'
|
require 'ostruct'
|
||||||
|
|
||||||
desc "build the browser spec runner.html based on current tree"
|
desc "build the browser spec for Jasmine core based on current tree"
|
||||||
task :build_runner_html do
|
task :build_runner_html do
|
||||||
template = Tilt.new('spec/templates/runner.html.erb')
|
template = Tilt.new('spec/templates/runner.html.erb')
|
||||||
|
|
||||||
File.open('spec/runner.html', 'w+') do |f|
|
File.open('spec/runner.html', 'w+') do |f|
|
||||||
scope = OpenStruct.new(:source_tags => other_source_file_tags,
|
scope = OpenStruct.new(:title => "Jasmine Spec Runner: Jasmine Core",
|
||||||
|
:favicon => favicon,
|
||||||
|
:jasmine_tags => core_jasmine_tags,
|
||||||
|
:source_tags => other_source_file_tags,
|
||||||
:spec_file_tags => spec_file_tags)
|
:spec_file_tags => spec_file_tags)
|
||||||
f << template.render(scope)
|
f << template.render(scope)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def favicon
|
||||||
|
<<HTML
|
||||||
|
<link rel="shortcut icon" type="image/png" href="../images/jasmine_favicon.png">
|
||||||
|
HTML
|
||||||
|
end
|
||||||
|
|
||||||
|
def core_jasmine_tags
|
||||||
|
tags = %Q{<link href="../lib/jasmine.css" rel="stylesheet"/>}
|
||||||
|
tags << "\n "
|
||||||
|
tags << script_tags_for("../lib/jasmine.js")
|
||||||
|
tags << "\n "
|
||||||
|
tags << undefined_catch
|
||||||
|
tags
|
||||||
|
end
|
||||||
|
|
||||||
|
def undefined_catch
|
||||||
|
<<HTML
|
||||||
|
<script type="text/javascript">
|
||||||
|
// yes, really keep this here to keep us honest, but only for jasmine's own runner! [xw]
|
||||||
|
undefined = "diz be undefined yo";
|
||||||
|
</script>
|
||||||
|
HTML
|
||||||
|
end
|
||||||
|
|
||||||
def other_source_file_tags
|
def other_source_file_tags
|
||||||
other_files = html_sources + console_sources
|
other_files = html_sources + console_sources
|
||||||
script_tags_for other_files.collect { |f| "../#{f}" }
|
script_tags_for other_files.collect { |f| "../#{f}" }
|
||||||
@@ -21,12 +48,3 @@ def spec_file_tags
|
|||||||
script_tags_for spec_files.collect { |f| "../#{f}" }
|
script_tags_for spec_files.collect { |f| "../#{f}" }
|
||||||
end
|
end
|
||||||
|
|
||||||
def script_tags_for(files)
|
|
||||||
script_tag = Tilt::new('spec/templates/script_tag.html.erb')
|
|
||||||
|
|
||||||
files.inject([]) do |tags, f|
|
|
||||||
scope = OpenStruct.new :file => f
|
|
||||||
tags << script_tag.render(scope)
|
|
||||||
tags
|
|
||||||
end.join("\n ")
|
|
||||||
end
|
|
||||||
@@ -35,3 +35,13 @@ end
|
|||||||
def version_hash
|
def version_hash
|
||||||
@version ||= JSON.parse(File.new("src/version.json").read);
|
@version ||= JSON.parse(File.new("src/version.json").read);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def script_tags_for(files)
|
||||||
|
script_tag = Tilt::new('spec/templates/script_tag.html.erb')
|
||||||
|
|
||||||
|
files.inject([]) do |tags, f|
|
||||||
|
scope = OpenStruct.new :file => f
|
||||||
|
tags << script_tag.render(scope)
|
||||||
|
tags
|
||||||
|
end.join("\n ")
|
||||||
|
end
|
||||||
@@ -1,34 +1,84 @@
|
|||||||
desc "Build example project"
|
require 'ostruct'
|
||||||
task :build_example_project => :need_pages_submodule do
|
|
||||||
|
desc "Build standalone distribution, block if zip of current version"
|
||||||
|
task :standalone_safe => [:require_pages_submodule, :protect_current_dist_zip, :build_spec_runner_html]
|
||||||
|
|
||||||
|
desc "Build standalone distribution"
|
||||||
|
task :standalone => [:require_pages_submodule, :build_spec_runner_html] do
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
|
|
||||||
temp_dir = File.join(Dir.tmpdir, 'jasmine-standalone-project')
|
zip_root = File.join(Dir.tmpdir, "zip_root")
|
||||||
|
temp_dir = File.join(zip_root, "jasmine-standalone-#{version_string}")
|
||||||
puts "Building Example Project in #{temp_dir}"
|
puts "Building Example Project in #{temp_dir}"
|
||||||
FileUtils.rm_r temp_dir if File.exist?(temp_dir)
|
FileUtils.rm_r temp_dir if File.exist?(temp_dir)
|
||||||
Dir.mkdir(temp_dir)
|
FileUtils.mkdir_p(temp_dir)
|
||||||
|
|
||||||
root = File.expand_path(File.dirname(__FILE__))
|
root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
||||||
FileUtils.cp_r File.join(root, 'example/.'), File.join(temp_dir)
|
FileUtils.cp_r File.join(root, 'example/.'), File.join(temp_dir)
|
||||||
substitute_jasmine_version(File.join(temp_dir, "SpecRunner.html"))
|
|
||||||
|
|
||||||
lib_dir = File.join(temp_dir, "lib/jasmine-#{jasmine_version}")
|
lib_dir = File.join(temp_dir, "lib/jasmine-#{version_string}")
|
||||||
FileUtils.mkdir_p(lib_dir)
|
FileUtils.mkdir_p(lib_dir)
|
||||||
{
|
{
|
||||||
"lib/jasmine.js" => "jasmine.js",
|
"images/jasmine_favicon.png" => "jasmine_favicon.png",
|
||||||
"lib/jasmine-html.js" => "jasmine-html.js",
|
"lib/jasmine.js" => "jasmine.js",
|
||||||
"src/html/jasmine.css" => "jasmine.css",
|
"lib/jasmine-html.js" => "jasmine-html.js",
|
||||||
"MIT.LICENSE" => "MIT.LICENSE"
|
"src/html/jasmine.css" => "jasmine.css",
|
||||||
|
"MIT.LICENSE" => "MIT.LICENSE"
|
||||||
}.each_pair do |src, dest|
|
}.each_pair do |src, dest|
|
||||||
FileUtils.cp(File.join(root, src), File.join(lib_dir, dest))
|
FileUtils.cp(File.join(root, src), File.join(lib_dir, dest))
|
||||||
end
|
end
|
||||||
|
|
||||||
dist_dir = File.join(root, 'pages/downloads')
|
dist_dir = File.join(root, 'pages/downloads')
|
||||||
zip_file_name = File.join(dist_dir, "jasmine-standalone-#{jasmine_version}.zip")
|
zip_file_name = File.join(dist_dir, "jasmine-standalone-#{version_string}.zip")
|
||||||
|
|
||||||
puts "Zipping Example Project and moving to #{zip_file_name}"
|
puts "Zipping Example Project and moving to #{zip_file_name}"
|
||||||
FileUtils.mkdir(dist_dir) unless File.exist?(dist_dir)
|
exec "cd #{zip_root} && zip #{zip_file_name} -r . -x .[a-zA-Z0-9]*"
|
||||||
if File.exist?(zip_file_name)
|
end
|
||||||
puts "WARNING!!! #{zip_file_name} already exists!"
|
|
||||||
FileUtils.rm(zip_file_name)
|
desc "Build SpecRunner.html for standalone dist example project"
|
||||||
end
|
task :build_spec_runner_html do
|
||||||
exec "cd #{temp_dir} && zip -r #{zip_file_name} . -x .[a-zA-Z0-9]*"
|
template = Tilt.new('spec/templates/runner.html.erb')
|
||||||
|
|
||||||
|
File.open('example/SpecRunner.html', 'w+') do |f|
|
||||||
|
scope = OpenStruct.new(:title => "Jasmine Spec Runner",
|
||||||
|
:favicon => example_favicon,
|
||||||
|
:jasmine_tags => example_jasmine_tags,
|
||||||
|
:source_tags => example_source_tags,
|
||||||
|
:spec_file_tags => example_spec_tags)
|
||||||
|
f << template.render(scope)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def example_path
|
||||||
|
"lib/jasmine-#{version_string}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def example_favicon
|
||||||
|
<<HTML
|
||||||
|
<link rel="shortcut icon" type="image/png" href="#{example_path}/jasmine_favicon.png">
|
||||||
|
HTML
|
||||||
|
end
|
||||||
|
|
||||||
|
def example_jasmine_tags
|
||||||
|
tags = %Q{<link rel="stylesheet" type="text/css" href="#{example_path}/jasmine.css">}
|
||||||
|
tags << "\n "
|
||||||
|
tags << script_tags_for(["#{example_path}/jasmine.js", "#{example_path}/jasmine-html.js"])
|
||||||
|
tags
|
||||||
|
end
|
||||||
|
|
||||||
|
def example_source_tags
|
||||||
|
script_tags_for ['spec/SpecHelper.js', 'spec/PlayerSpec.js']
|
||||||
|
end
|
||||||
|
|
||||||
|
def example_spec_tags
|
||||||
|
script_tags_for ['src/Player.js', 'src/Song.js']
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
task :protect_current_dist_zip do
|
||||||
|
root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
||||||
|
dist_dir = File.join(root, 'pages/downloads')
|
||||||
|
zip_file_name = File.join(dist_dir, "jasmine-standalone-#{version_string}.zip")
|
||||||
|
|
||||||
|
raise "STOPPED: #{zip_file_name} already exists" if File.exist?(zip_file_name)
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user