7 Replies Latest reply on Oct 20, 2010 9:00 AM by Wijnand_

    Passing extra compiler options to <flexunit> ANT task?

    Wijnand_ Level 1

      Hi,

       

      Is there a way to send any extra compiler options to the <flexunit> ANT task?

      I'm using conditional compilation and compilation (mxmlc) is failing from the <flexunit> task:

       

      "Error: Access of undefined property DEBUG.

      CONFIG::DEBUG {"

       

      I tried sneaking "-define+=CONFIG::DEBUG,false" in with one of the other compiler options you can set on the <flexunit> task, but that just doesn't work or results in a validation error like this:

       

      "One of the directories specified as a 'testSource' element does not exist."

       

      Let me know if this is possible at all.

      Thanks,

       

      Wijnand

        • 1. Re: Passing extra compiler options to <flexunit> ANT task?
          Wijnand_ Level 1

          I think I found a workable work around in one of the other threads. A small comment by Brian, that seems to do the trick:

          "The implementation for 4.1 was left relatively simple for a first round since the alternative always exists to compile your test SWF" (http://forums.adobe.com/message/2897068#2897068)

           

          So by using the snippet below, you can test your own SWF with the <flexunit> ANT task:

          "<flexunit
                      workingDir="c:\project\working"
                      toDir="c:\project\reports"
                      haltonfailure="false"
                      verbose="true"
                      localTrusted="true"
                      swf="c:\project\working\test.swf">"

          • 2. Re: Passing extra compiler options to <flexunit> ANT task?
            legrosb Level 3

            @Wijnand - Sorry for the belated response.  I thought I had captured this on the wiki, but it looks like I haven't, so thank you for the heads up.  Indeed the goal is to take a simple approach to compilation initially since mapping all of the actual compiler flags for MXMLC could provide a challenge.  It's good to see use cases however for potential new features.  In 4.2, which is super pre-alpha right now, I've added support to accept a series of flex-config.xml files provided by the user.  Not sure if conditional compilation can be tackled with a custom flex-config.xml file, but if so then that'd be the feature that may help you. 

             

            I'd encourage you to file a New Feature Request on JIRA so I can keep track of the use cases people have for compilation, so I can support them in 4.2.  I'll also update the wiki @ http://docs.flexunit.org/index.php?title=Ant_Task to be more detailed regarding compilation so other don't have to dig.  Thanks again.

             

            -Brian

            • 3. Re: Passing extra compiler options to <flexunit> ANT task?
              Wijnand_ Level 1

              Hi Brian,

               

              legrosb wrote:

               

              @Wijnand - Sorry for the belated response.

              Not late at all! I think a response within a day on a forum is quite fast!

               

              legrosb wrote:

               

              I thought I had captured this on the wiki, but it looks like I haven't, so thank you for the heads up.


              I'll also update the wiki @ http://docs.flexunit.org/index.php?title=Ant_Task to be more detailed regarding compilation so other don't have to dig. 

               

              Did you just do an update on that Wiki page or did I completely miss the part that explained the <flexunit> parameters?

               

              legrosb wrote:

               

              In 4.2, which is super pre-alpha right now, I've added support to accept a series of flex-config.xml files provided by the user.  Not sure if conditional compilation can be tackled with a custom flex-config.xml file, but if so then that'd be the feature that may help you.

              Yes, being able to add (+=) a custom config file will solve this problem for me. You can define properties and values like this:

               

              <flex-config>

                  <compiler>
                      <define>
                          <name>CONFIG::DEBUG</name>
                          <value>false</value>
                      </define>

                  </compiler>

              <flex-config>

               

              So in your AS code you can use:

               

              CONFIG::DEBUG {

                  // Do something that only should be done in debug mode.

              }

               

               

              I have another question, I ran into this one during testing my SWF with flexunit.

              unittest.xml:82: java.util.concurrent.ExecutionException: command [<testcase classname='com.tuenti.video.unittest.testcase.player::MockPlayerCase' name='loadPlayer' time='0.000'  status='success'/>] not understood

              I had a look at the FlexUnitSocketThread.parseInboundMessages method that throws this error and it looks like that your defined END_OF_SUCCESS doesn't entirely match what the SWF is spitting out. They are of by 1 space: END_OF_SUCCESS is defined as: "status=\"success\" />", whereas my SWF spits out the following: "status='success'/>" (single quotes and no space before the closing of the tag).

              It looks like I'm not the only one with the ExecutionException as it is reported on StackOverflow as well: http://stackoverflow.com/questions/3953677/flexunittasks-error-of-command-not-understood

               

              Cheers,

               

              Wijnand

              • 4. Re: Passing extra compiler options to <flexunit> ANT task?
                legrosb Level 3

                @Wijnand - The wiki page has always been there, I just added a sentence talking about compilation this morning.  Glad to hear the custom flex-config will help, I think there is a feature request in JIRA if you want to vote on it to show your support.  As far as the error you're getting, I believe that is due to a mismatch in version of the CIListener library.  CIListener was updated for 4.1 and test runner's built with 4.0 will cause errors with the 4.1 Ant task.  Probably something additional we could add to the wiki; I'll get on that.  Double thanks!

                 

                -Brian

                • 5. Re: Passing extra compiler options to <flexunit> ANT task?
                  Wijnand_ Level 1

                  legrosb wrote:

                   

                  Glad to hear the custom flex-config will help, I think there is a feature request in JIRA if you want to vote on it to show your support.

                  Voted for https://bugs.adobe.com/jira/browse/FXU-116

                   

                  legrosb wrote:

                   

                  As far as the error you're getting, I believe that is due to a mismatch in version of the CIListener library.  CIListener was updated for 4.1 and test runner's built with 4.0 will cause errors with the 4.1 Ant task.  Probably something additional we could add to the wiki; I'll get on that.  Double thanks!

                   

                  -Brian

                  Glad I could help and thank you for replying so fast!

                  I'm working with matching versions now and I get a nice XML report! Fantastic!

                  I had to revert to 4.0.0 because I was getting the following error with 4.1.0, though I don't think I'm missing any vital functionality from 4.1 in 4.0.

                   

                  ...\libs\flexunit-cilistener-4.1.0.swc(org/flexunit/listeners/CIListener)
                  Error: Type was not found or was not a compile-time constant: [org.flexunit.runner.notification]::ITemporalRunListener.

                   

                  Thanks again,

                   

                  Wijnand

                  • 6. Re: Passing extra compiler options to <flexunit> ANT task?
                    legrosb Level 3

                    @Wijnand_ - The error you're receiving looks like a compile error because the flexunit SWC is missing from the library path.  Make sure you're using all 4.1 artifacts and that the flexunit SWC is on your path when compiling.  If this is the case and you're still receiving that error, let me know and we'll dig in more deeply.  In terms of inter-project dependencies, nothing has changed from 4.0 to 4.1 that should cause this error, so let's make sure it's just something with your setup.  ITemporalRunListener was introduced in 4.1, so maybe you have the flexunit 4.0.0 SWC on your path?

                     

                    Let us know.

                     

                    -Brian

                    • 7. Re: Passing extra compiler options to <flexunit> ANT task?
                      Wijnand_ Level 1

                      Ah yes, I was compiling using the Flex Unit 4.0 SWC.

                      Gotta love version mix ups!