restructured unit tests and created a unit test build target which concatenates source test files

This commit is contained in:
Eric Rowell
2012-11-13 21:37:28 -08:00
parent 5be1802729
commit a5e23c426d
29 changed files with 11470 additions and 4959 deletions

View File

@@ -9,12 +9,35 @@ class Build < Thor
"src/Animation.js", "src/Node.js", "src/DragAndDrop.js", "src/Transition.js", "src/Container.js", "src/Stage.js", "src/Layer.js", "src/Group.js", "src/Shape.js",
"src/shapes/Rect.js", "src/shapes/Circle.js", "src/shapes/Ellipse.js", "src/shapes/Image.js", "src/shapes/Polygon.js", "src/shapes/Text.js", "src/shapes/Line.js", "src/shapes/Sprite.js", "src/shapes/Star.js", "src/shapes/RegularPolygon.js", "src/shapes/Path.js", "src/shapes/TextPath.js"
]
UNIT_TESTS = [
"tests/js/unit/nodeTests.js",
"tests/js/unit/stageTests.js",
"tests/js/unit/containerTests.js",
"tests/js/unit/layerTests.js",
"tests/js/unit/shapeTests.js",
"tests/js/unit/ddTests.js",
"tests/js/unit/customShapeTests.js",
"tests/js/unit/animationTests.js",
"tests/js/unit/transitionTests.js",
"tests/js/unit/shapes/rectTests.js",
"tests/js/unit/shapes/circleTests.js",
"tests/js/unit/shapes/ellipseTests.js",
"tests/js/unit/shapes/imageTests.js",
"tests/js/unit/shapes/polygonTests.js",
"tests/js/unit/shapes/lineTests.js",
"tests/js/unit/shapes/regularPolygonTests.js",
"tests/js/unit/shapes/starTests.js",
"tests/js/unit/shapes/textTests.js",
"tests/js/unit/shapes/pathTests.js"
]
if !File.directory?("dist")
puts ":: Creating dist directory..."
Dir.mkdir("dist")
end
# dev build
desc "dev", "Concatenate all the js files into /dist/kinetic-VERSION.js."
def dev(version)
@@ -36,6 +59,26 @@ class Build < Thor
puts " -> Done!"
end
# test build
desc "test", "Concatenate all the unit test js files into tests/js/unitTests.js"
def test()
file_name = "tests/js/unitTests.js"
puts ":: Deleting old unitTests.js..."
if File.file?("tests/js/unitTests.js")
File.delete("tests/js/unitTests.js")
end
puts ":: Building new unitTests.js..."
File.open(file_name, "w") do |file|
file.puts concatenateUnitTests
end
puts " -> Done!"
end
#prod build
desc "prod", "Concatenate all the js files in into /dist/kinetic-VERSION.min.js and minify it."
def prod(version)
file_name = "dist/kinetic-#{version}.min.js"
@@ -51,13 +94,11 @@ class Build < Thor
#build full minfiied prod file
#=begin
File.open(file_name, "w") do |file|
uglify = Uglifier.compile(concatenate())
uglify.sub!(/\*\/ .+ \*\//xm, "*/")
file.puts replace_tokens(uglify, version)
end
#=end
#build modular minified files
puts ":: Building minified modules..."
@@ -86,6 +127,15 @@ class Build < Thor
return content
end
def concatenateUnitTests()
content = ""
UNIT_TESTS.each do |file|
content << IO.read(File.expand_path(file)) << "\n"
end
return content
end
def replace_tokens(content, version)
date = Time.now.strftime("%b %d %Y")