Browse files

[gh-7] Standardize the behavior of options for the flex compilers to …

…reflect the documentation. This actually fixes bugs where certain options were *not* properly manifested to the actual compilers. For instance it was impossible to set -use-network=false prior to this fix.
  • Loading branch information...
1 parent 9fc726c commit 9402bc4e0945c3df288c35b697e9af165eafd836 @apinstein apinstein committed Sep 5, 2011
Showing with 259 additions and 10 deletions.
  1. +46 −10 lib/flashsdk/compiler_base.rb
  2. +213 −0 test/unit/flex_compiler_options_test.rb
View
56 lib/flashsdk/compiler_base.rb
@@ -53,8 +53,8 @@ class CompilerBase < Sprout::Executable::Base
# t.as3 = false
# end
#
- add_param :as3, Boolean, { :default => true, :show_on_false => true }
-
+ add_param :as3, Boolean, { :default => true, :show_on_false => true, :hidden_value => false, :delimiter => '=' }
+
##
# Prints detailed compile times to the standard output. The default value is true.
#
@@ -65,8 +65,8 @@ class CompilerBase < Sprout::Executable::Base
# t.benchmark = true
# end
#
- add_param :benchmark, Boolean, { :default => true, :show_on_false => true }
-
+ add_param :benchmark, Boolean, { :default => true, :show_on_false => true, :hidden_value => false, :delimiter => '=' }
+
##
# Sets the value of the {context.root} token in channel definitions in the flex-services.xml file. If you do not specify the value of this option, Flex uses an empty string.
#
@@ -718,7 +718,7 @@ class CompilerBase < Sprout::Executable::Base
#
# @see #debug
#
- add_param :optimize, Boolean
+ add_param :optimize, Boolean, { :default => true, :show_on_false => true, :hidden_value => false, :delimiter => '=' }
##
# Specifies the output path and filename for the resulting file.
@@ -823,7 +823,7 @@ class CompilerBase < Sprout::Executable::Base
# t.show_actionscript_warnings = false
# end
#
- add_param :show_actionscript_warnings, Boolean, { :default => true, :show_on_false => true }
+ add_param :show_actionscript_warnings, Boolean, { :default => true, :show_on_false => true, :hidden_value => false, :delimiter => '=' }
##
# Shows a warning when Flash Player cannot detect changes to a bound property.
@@ -837,7 +837,36 @@ class CompilerBase < Sprout::Executable::Base
# t.show_binding_warnings = false
# end
#
- add_param :show_binding_warnings, Boolean, { :default => true, :show_on_false => true }
+ add_param :show_binding_warnings, Boolean, { :default => true, :show_on_false => true, :hidden_value => false, :delimiter => '=' }
+
+ ##
+ # Shows warnings when you try to embed a font with a family name that is the same as the operating system font name.
+ # The compiler normally warns you that you are shadowing a system font. Set this option to false to disable the warnings.
+ #
+ # The default value is true.
+ #
+ # desc "Compile the Application"
+ # mxmlc 'bin/SomeProject.swf' do |t|
+ # t.input = 'src/SomeProject.mxml'
+ # t.source_path << 'src'
+ # t.show_shadowed_device_font_warnings = false
+ # end
+ #
+ add_param :show_shadowed_device_font_warnings, Boolean, { :default => true, :show_on_false => true, :hidden_value => false, :delimiter => '=' }
+
+ ##
+ # Shows warnings when a type selector in a style sheet or <mx:Style> block is not used by any components in the application.
+ #
+ # The default value is true.
+ #
+ # desc "Compile the Application"
+ # mxmlc 'bin/SomeProject.swf' do |t|
+ # t.input = 'src/SomeProject.mxml'
+ # t.source_path << 'src'
+ # t.show_unused_type_selector_warnings = false
+ # end
+ #
+ add_param :show_unused_type_selector_warnings, Boolean, { :default => true, :show_on_false => true, :hidden_value => false, :delimiter => '=' }
##
# Shows deprecation warnings for Flex components. To see warnings for ActionScript classes, use the show-actionscript-warnings option.
@@ -905,7 +934,7 @@ class CompilerBase < Sprout::Executable::Base
# t.strict = false
# end
#
- add_param :strict, Boolean, { :default => true, :show_on_false => true }
+ add_param :strict, Boolean, { :default => true, :show_on_false => true, :hidden_value => false, :delimiter => '=' }
##
# Specifies the version of the player the application is targeting.
@@ -945,7 +974,14 @@ class CompilerBase < Sprout::Executable::Base
# with file: URLs) but not network services. In most circumstances, the
# value of this property should be true.
#
- add_param :use_network, Boolean, { :default => true, :show_on_false => true }
+ add_param :use_network, Boolean, { :default => true, :show_on_false => true, :hidden_value => false, :delimiter => '=' }
+
+ ##
+ # Enables resource bundles. Set to true to instruct the compiler to process the contents of the [ResourceBundle] metadata tag.
+ #
+ # The default value is true.
+ #
+ add_param :use_resource_bundle_metadata, Boolean, { :default => true, :show_on_false => true, :hidden_value => false, :delimiter => '=' }
##
# Generates source code that includes source files and line numbers. When
@@ -974,7 +1010,7 @@ class CompilerBase < Sprout::Executable::Base
#
# The default value is true.
#
- add_param :warnings, Boolean
+ add_param :warnings, Boolean, { :default => true, :show_on_false => true, :hidden_value => false, :delimiter => '=' }
##
# Set to true in order to compile with the Flex Compiler Shell (FCSH).
View
213 test/unit/flex_compiler_options_test.rb
@@ -0,0 +1,213 @@
+require 'test_helper'
+
+class FlexCompilerOptionsTest < Test::Unit::TestCase
+ include Sprout::TestHelper
+
+ # formal tests for a variety of Flex compiler options and how they should appear on the CLI based on true/false settings
+ context "A Flex compiler's options" do
+
+ setup do
+ @mxmlc = FlashSDK::MXMLC.new
+ end
+
+ teardown do
+ end
+
+ # -as3
+ should "default to as3=true" do
+ assert_equal true, @mxmlc.as3
+ end
+
+ should "not include a -as3 flag if :as3 is set to true" do
+ @mxmlc.as3 = true
+ assert_no_match /-as3/, @mxmlc.to_shell
+ end
+
+ should "include -as3=false flag if :as3 is set to false" do
+ @mxmlc.as3 = false
+ assert_equal '-as3=false', @mxmlc.to_shell
+ end
+
+ # -benchmark
+ should "default to benchmark=true" do
+ assert_equal true, @mxmlc.benchmark
+ end
+
+ should "not include a -benchmark flag if :benchmark is set to true" do
+ @mxmlc.benchmark = true
+ assert_no_match /-benchmark/, @mxmlc.to_shell
+ end
+
+ should "include -benchmark=false flag if :benchmark is set to false" do
+ @mxmlc.benchmark = false
+ assert_equal '-benchmark=false', @mxmlc.to_shell
+ end
+
+ # -debug
+ should "default to debug=false" do
+ assert_equal false, @mxmlc.debug
+ end
+
+ should "not include a -debug flag if :debug is set to false" do
+ assert_no_match /-debug/, @mxmlc.to_shell
+ end
+
+ should "include -debug flag if :debug is set to true" do
+ @mxmlc.debug = true
+ assert_equal '-debug', @mxmlc.to_shell
+ end
+
+ # -use-network
+ should "default to use_network=false" do
+ assert_equal true, @mxmlc.use_network
+ end
+
+ should "not include a -use-network flag if :use_network is set to true" do
+ @mxmlc.use_network = true
+ assert_no_match /-use-network/, @mxmlc.to_shell
+ end
+
+ should "include -use-network=false flag if :use_network is set to false" do
+ @mxmlc.use_network = false
+ assert_equal '-use-network=false', @mxmlc.to_shell
+ end
+
+ # -optimize
+ should "default to optimize=true" do
+ assert_equal true, @mxmlc.optimize
+ end
+
+ should "not include a -optimize flag if :optimize is set to true" do
+ @mxmlc.optimize = true
+ assert_no_match /-optimize/, @mxmlc.to_shell
+ end
+
+ should "include -optimize=false flag if :optimize is set to false" do
+ @mxmlc.optimize = false
+ assert_equal '-optimize=false', @mxmlc.to_shell
+ end
+
+ # -show-actionscript-warnings
+ should "default to show-actionscript-warnings=true" do
+ assert_equal true, @mxmlc.show_actionscript_warnings
+ end
+
+ should "not include a -show-actionscript-warnings flag if :show-actionscript-warnings is set to true" do
+ @mxmlc.show_actionscript_warnings = true
+ assert_no_match /-show-actionscript-warnings/, @mxmlc.to_shell
+ end
+
+ should "include -show-actionscript-warnings=false flag if :show-actionscript-warnings is set to false" do
+ @mxmlc.show_actionscript_warnings = false
+ assert_equal '-show-actionscript-warnings=false', @mxmlc.to_shell
+ end
+
+ # -show-binding-warnings
+ should "default to show-binding-warnings=true" do
+ assert_equal true, @mxmlc.show_binding_warnings
+ end
+
+ should "not include a -show-binding-warnings flag if :show-binding-warnings is set to true" do
+ @mxmlc.show_binding_warnings = true
+ assert_no_match /-show-binding-warnings/, @mxmlc.to_shell
+ end
+
+ should "include -show-binding-warnings=false flag if :show-binding-warnings is set to false" do
+ @mxmlc.show_binding_warnings = false
+ assert_equal '-show-binding-warnings=false', @mxmlc.to_shell
+ end
+
+ # -show-shadowed-device-font-warnings
+ should "default to show-shadowed-device-font-warnings=true" do
+ assert_equal true, @mxmlc.show_shadowed_device_font_warnings
+ end
+
+ should "not include a -show-shadowed-device-font-warnings flag if :show-shadowed-device-font-warnings is set to true" do
+ @mxmlc.show_shadowed_device_font_warnings = true
+ assert_no_match /-show-shadowed-device-font-warnings/, @mxmlc.to_shell
+ end
+
+ should "include -show-shadowed-device-font-warnings=false flag if :show-shadowed-device-font-warnings is set to false" do
+ @mxmlc.show_shadowed_device_font_warnings = false
+ assert_equal '-show-shadowed-device-font-warnings=false', @mxmlc.to_shell
+ end
+
+ # -show-unused-type-selector-warnings
+ should "default to show-unused-type-selector-warnings=true" do
+ assert_equal true, @mxmlc.show_unused_type_selector_warnings
+ end
+
+ should "not include a -show-unused-type-selector-warnings flag if :show-unused-type-selector-warnings is set to true" do
+ @mxmlc.show_unused_type_selector_warnings = true
+ assert_no_match /-show-unused-type-selector-warnings/, @mxmlc.to_shell
+ end
+
+ should "include -show-unused-type-selector-warnings=false flag if :show-unused-type-selector-warnings is set to false" do
+ @mxmlc.show_unused_type_selector_warnings = false
+ assert_equal '-show-unused-type-selector-warnings=false', @mxmlc.to_shell
+ end
+
+ # -static-link-runtime-shared-libraries
+ should "default to static-link-runtime-shared-libraries=true" do
+ assert_equal true, @mxmlc.static_link_runtime_shared_libraries
+ end
+
+ should "not include a -static-link-runtime-shared-libraries flag if :static-link-runtime-shared-libraries is set to true" do
+ @mxmlc.static_link_runtime_shared_libraries = true
+ assert_no_match /-static-link-runtime-shared-libraries/, @mxmlc.to_shell
+ end
+
+ should "include -static-link-runtime-shared-libraries=false flag if :static-link-runtime-shared-libraries is set to false" do
+ @mxmlc.static_link_runtime_shared_libraries = false
+ assert_equal '-static-link-runtime-shared-libraries=false', @mxmlc.to_shell
+ end
+
+ # -strict
+ should "default to strict=true" do
+ assert_equal true, @mxmlc.strict
+ end
+
+ should "not include a -strict flag if :strict is set to true" do
+ @mxmlc.strict = true
+ assert_no_match /-strict/, @mxmlc.to_shell
+ end
+
+ should "include -strict=false flag if :strict is set to false" do
+ @mxmlc.strict = false
+ assert_equal '-strict=false', @mxmlc.to_shell
+ end
+
+ # -use-resource-bundle-metadata
+ should "default to use-resource-bundle-metadata=true" do
+ assert_equal true, @mxmlc.use_resource_bundle_metadata
+ end
+
+ should "not include a -use-resource-bundle-metadata flag if :use-resource-bundle-metadata is set to true" do
+ @mxmlc.use_resource_bundle_metadata = true
+ assert_no_match /-use-resource-bundle-metadata/, @mxmlc.to_shell
+ end
+
+ should "include -use-resource-bundle-metadata=false flag if :use-resource-bundle-metadata is set to false" do
+ @mxmlc.use_resource_bundle_metadata = false
+ assert_equal '-use-resource-bundle-metadata=false', @mxmlc.to_shell
+ end
+
+ # -warnings
+ should "default to warnings=true" do
+ assert_equal true, @mxmlc.warnings
+ end
+
+ should "not include a -warnings flag if :warnings is set to true" do
+ @mxmlc.warnings = true
+ assert_no_match /-warnings/, @mxmlc.to_shell
+ end
+
+ should "include -warnings=false flag if :warnings is set to false" do
+ @mxmlc.warnings = false
+ assert_equal '-warnings=false', @mxmlc.to_shell
+ end
+
+
+ end
+end
+

0 comments on commit 9402bc4

Please sign in to comment.