Skip to content

Commit

Permalink
Integrated ProjectSprouts prelease support
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebayes committed Jul 4, 2010
1 parent a37c077 commit 577c94f
Show file tree
Hide file tree
Showing 18 changed files with 328 additions and 83 deletions.
9 changes: 9 additions & 0 deletions asunit-4.0/Gemfile
@@ -0,0 +1,9 @@
source :rubygems

gem 'flashsdk', '>= 1.0.2.pre'

group :development do
gem "shoulda"
gem "mocha"
end

32 changes: 13 additions & 19 deletions asunit-4.0/asunit4.gemspec
@@ -1,26 +1,20 @@
# -*- encoding: utf-8 -*-

require File.dirname(__FILE__) + '/config/version'
require File.join(File.dirname(__FILE__), 'sprout', 'lib', 'asunit4')
require 'rake'

# This file is actually executed from dist/
# Check the rakefile.rb for more information.

Gem::Specification.new do |s|
s.name = "sprout-asunit4"
s.version = AsUnit::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Luke Bayes, Ali Mills and Robert Penner"]
s.email = ["asunit-users@lists.sourceforge.net"]
s.homepage = "http://asunit.org"
s.summary = "The fastest and most flexible ActionScript unit test framework"
s.description = "AsUnit is the only ActionScript unit test framework that support every development and runtime environment that is currently available. This includes Flex 2, 3, 4, AIR 1 and 2, Flash Lite, and of course the Flash Authoring tool"

s.name = AsUnit::NAME
s.version = AsUnit::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Luke Bayes", "Ali Mills", "Robert Penner"]
s.email = ["asunit-users@lists.sourceforge.net"]
s.homepage = "http://asunit.org"
s.summary = "The fastest and most flexible ActionScript unit test framework"
s.description = "AsUnit is the only ActionScript unit test framework that support every development and runtime environment that is currently available. This includes Flex 2, 3, 4, AIR 1 and 2, Flash Lite, and of course the Flash Authoring tool"
s.rubyforge_project = "sprout"
s.required_rubygems_version = ">= 1.3.6"
s.rubyforge_project = "sprout"

included_files = FileList["**/*"].exclude /.DS_Store|generated|.svn|.git|airglobal.swc|airframework.swc/

s.files = included_files
s.require_path = 'config'
s.require_path = "sprout/lib"
s.files = FileList["**/*"].exclude /docs|.DS_Store|generated|.svn|.git|airglobal.swc|airframework.swc/
end

10 changes: 0 additions & 10 deletions asunit-4.0/config/asunit.rb

This file was deleted.

5 changes: 0 additions & 5 deletions asunit-4.0/config/version.rb

This file was deleted.

86 changes: 59 additions & 27 deletions asunit-4.0/rakefile.rb
@@ -1,7 +1,8 @@
require 'sprout'
sprout 'as3'
require 'bundler'
Bundler.require

require File.dirname(__FILE__) + '/config/version'
require 'rake/clean'
require File.join(File.dirname(__FILE__), 'sprout', 'lib', 'asunit4')

test_input = "AsUnitRunner"

Expand Down Expand Up @@ -37,7 +38,7 @@ def apply_as3_meta_data_args(t)
# Configure a Test Build:

def configure_test_task(t)
t.default_size = '1000 600'
t.default_size = '1000,600'
t.source_path << 'src'
t.library_path << 'lib/Reflection.swc'
t.debug = true
Expand All @@ -51,28 +52,28 @@ def configure_test_task(t)
desc "Compile the ActionScript test harness"
mxmlc "bin/#{test_input}.swf" do |t|
t.input = "test/AsUnitRunner.as"
t.gem_name = 'sprout-flex4sdk-tool'
t.pkg_name = 'flex4'
configure_test_task t
end

desc "Compile the Flex 3 test harness"
mxmlc "bin/Flex3#{test_input}.swf" do |t|
t.input = "test/Flex3Runner.mxml"
t.gem_name = 'sprout-flex3sdk-tool'
t.pkg_name = 'flex3'
configure_test_task t
end

desc "Compile the Flex 4 test harness"
mxmlc "bin/Flex4#{test_input}.swf" do |t|
t.input = "test/Flex4Runner.mxml"
t.gem_name = 'sprout-flex4sdk-tool'
t.pkg_name = 'flex4'
configure_test_task t
end

desc "Compile the Flex 4 test harness"
desc "Compile the AIR 2 test harness"
mxmlc "bin/AIR2#{test_input}.swf" do |t|
t.input = "air/AIR2Runner.mxml"
t.gem_name = 'sprout-flex4sdk-tool'
t.pkg_name = 'flex4'
t.source_path << 'air'
t.source_path << 'test'
t.library_path << 'lib/airglobal.swc'
Expand All @@ -92,50 +93,78 @@ def configure_test_task(t)
desc "Compile and run the Flex 4 Harness"
flashplayer :test_flex4 => "bin/Flex4#{test_input}.swf"

desc "Compile and run the AIR 2 Harness"
adl :test_air2 => "bin/AIR2#{test_input}.swf" do |t|
t.gem_name = "sprout-flex4sdk-tool"
t.root_directory = Dir.pwd
t.application_descriptor = "air/AIR2RunnerDescriptor.xml"
end
# TODO: Reactivate this once the new sprout harness
# support adl / adt

task :test_air2

#desc "Compile and run the AIR 2 Harness"
#adl :test_air2 => "bin/AIR2#{test_input}.swf" do |t|
#t.pkg_name = 'flex4'
#t.root_directory = Dir.pwd
#t.application_descriptor = "air/AIR2RunnerDescriptor.xml"
#end

desc "Compile and run the ActionScript 3 test harness"
task :test => :test_as3

desc "Compile and run test harnesses for all supported environments"
task :test_all => [:test_as3, :test_flex3, :test_flex4, :test_air2]

##########################################
# Run the Sprout Ruby tests

require 'rake/testtask'

namespace :sprout do
desc "Run the Sprout Generator tests"
Rake::TestTask.new(:test) do |t|
t.libs << "test/unit"
t.test_files = FileList["sprout/test/unit/*_test.rb"]
t.verbose = true
end
end

##########################################
# Compile the SWC

def configure_swc_task(t)
t.gem_name = 'sprout-flex4sdk-tool'
compc "bin/AsUnit-#{AsUnit::VERSION}.swc" do |t|
t.pkg_name = 'flex4'
t.include_sources << 'src'
t.source_path << 'src'
t.library_path << 'lib/Reflection.swc'
t.static_link_runtime_shared_libraries = true
apply_as3_meta_data_args(t)
end

compc "bin/AsUnit-#{AsUnit::VERSION}.swc" do |t|
configure_swc_task t
task :swc => "bin/AsUnit-#{AsUnit::VERSION}.swc"

##########################################
# Compile the Gem

file "bin/asunit4-#{AsUnit::VERSION}.gem" do
sh "gem build asunit4.gemspec"
mv "asunit4-#{AsUnit::VERSION}.gem", "bin/"
end

task :swc => "bin/AsUnit-#{AsUnit::VERSION}.swc"
CLEAN.add("bin/*.gem")

desc "Build the rubygem"
task :gem => [:clean, :swc, "bin/asunit4-#{AsUnit::VERSION}.gem"]

##########################################
# Generate documentation

desc "Generate documentation"
asdoc 'doc' do |t|
t.appended_args = '-examples-path=examples'
t.source_path << 'src'
t.doc_classes << 'AsUnit'
t.library_path << 'lib/Reflection.swc'
#desc "Generate documentation"
#asdoc 'doc' do |t|
#t.appended_args = '-examples-path=examples'
#t.source_path << 'src'
#t.doc_classes << 'AsUnit'
#t.library_path << 'lib/Reflection.swc'

# Not on asdoc?
#t.static_link_runtime_shared_libraries = true
end
#end

##########################################
# Package framework ZIPs
Expand All @@ -148,6 +177,8 @@ def configure_swc_task(t)

CLEAN.add '*.gem'

=begin
# TODO: Add back when zip task is working
archive = "AsUnit-#{AsUnit::VERSION}.zip"
zip archive do |t|
Expand All @@ -158,6 +189,7 @@ def configure_swc_task(t)
desc "Create zip archives"
task :zip => [:clean, :test_all, archive]
=end

##########################################
# Set up task wrappers
Expand Down
21 changes: 0 additions & 21 deletions asunit-4.0/script/generate

This file was deleted.

23 changes: 23 additions & 0 deletions asunit-4.0/sprout/lib/asunit4.rb
@@ -0,0 +1,23 @@
require 'flashsdk'

$:.unshift File.dirname(__FILE__)

module AsUnit
NAME = 'asunit4'
VERSION = '4.2.1.pre'
end

require 'asunit4/test_class_generator'
require 'asunit4/suite_class_generator'

Sprout::Specification.new do |s|
s.name = AsUnit::NAME
s.version = AsUnit::VERSION
s.add_file_target do |f|
f.add_library :swc, File.join('..', '..', 'bin', "AsUnit-#{AsUnit::VERSION}.swc")
# Removed the src compilation for now, b/c it requires additional compiler
# configuration - like keep-as3-metadata...
#f.add_library :src, [File.join(path, 'src'), File.join(path, 'vendor/as3reflection')]
end
end

17 changes: 17 additions & 0 deletions asunit-4.0/sprout/lib/asunit4/suite_class_generator.rb
@@ -0,0 +1,17 @@
module AsUnit4
class SuiteClassGenerator < FlashSDK::ClassGenerator
include FlashSDK::FlashHelper

def initialize
super
self.input = 'AllTests.as'
end

def manifest
directory test do
template input, 'AsUnit4SuiteClass.as'
end
end
end
end

18 changes: 18 additions & 0 deletions asunit-4.0/sprout/lib/asunit4/templates/AsUnit4SuiteClass.as
@@ -0,0 +1,18 @@
package {
/**
* This file has been automatically created using
* #!/usr/bin/ruby script/generate suite
* If you modify it and run this script, your
* modifications will be lost!
*/
<% test_case_classes.each do |test_case| %>import <%= test_case %>;
<% end %>

[Suite]
public class AllTests {
<% test_case_classes.each do |test_case| %>public var <%= test_case.gsub('.', '_') %>:<%= test_case %>;
<% end %>

}
}

33 changes: 33 additions & 0 deletions asunit-4.0/sprout/lib/asunit4/templates/AsUnit4TestClass.as
@@ -0,0 +1,33 @@
package <%= package_name %> {

import asunit.asserts.*;
import asunit.framework.IAsync;
import flash.display.Sprite;

public class <%= test_class_name %> {

[Inject]
public var async:IAsync;

[Inject]
public var context:Sprite;

private var <%= instance_name %>:<%= class_name %>;

[Before]
public function setUp():void {
<%= instance_name %> = new <%= class_name %>();
}

[After]
public function tearDown():void {
<%= instance_name %> = null;
}

[Test]
public function shouldBeInstantiated():void {
assertTrue("<%= instance_name %> is <%= class_name %>", <%= instance_name %> is <%= class_name %>);
}
}
}

15 changes: 15 additions & 0 deletions asunit-4.0/sprout/lib/asunit4/test_class_generator.rb
@@ -0,0 +1,15 @@

module AsUnit4
class TestClassGenerator < FlashSDK::ClassGenerator

def manifest
directory test_class_directory do
template "#{test_class_name}.as", 'AsUnit4TestClass.as'
end

generator :suite_class
end

end
end

13 changes: 13 additions & 0 deletions asunit-4.0/sprout/test/fixtures/tmp/test/AllTests.as
@@ -0,0 +1,13 @@
package {
/**
* This file has been automatically created using
* #!/usr/bin/ruby script/generate suite
* If you modify it and run this script, your
* modifications will be lost!
*/
import utils.MathUtilTest;
[Suite]
public class AllTests {
public var utils_MathUtilTest:utils.MathUtilTest; }
}

13 changes: 13 additions & 0 deletions asunit-4.0/sprout/test/fixtures/tmp/test/utils.MathUtil
@@ -0,0 +1,13 @@
package {
/**
* This file has been automatically created using
* #!/usr/bin/ruby script/generate suite
* If you modify it and run this script, your
* modifications will be lost!
*/
import utils.MathUtilTest;
[Suite]
public class AllTests {
public var utils_MathUtilTest:utils.MathUtilTest; }
}

0 comments on commit 577c94f

Please sign in to comment.