An indispensable tool for non-IDE ActionScript development
Ruby ActionScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
asspec/src/asautotest
bin
lib/asautotest
.gitignore
AUTHORS
LICENSE
README.rdoc
TODO
asautotest.gemspec

README.rdoc

ASAutotest

ASAutotest is an automatic compilation and testing tool ideally suited for non-IDE ActionScript development.

It operates by watching your entire source directory, triggering a recompilation as soon as any source file changes. Compilation errors are reported to the terminal in a nice way. To keep compilation times to a minimum, it uses the Flex Compiler Shell (FCSH).

There is also support for automatically running tests after a successful compilation, but this currently requires some manual glue, is undocumented and a bit hard to set up (once set up, though, it works really well). For a working example of the kind of glue you need, see <test-project/src/specification.as>.

Installation

The easiest way to install ASAutotest is via Rubygems:

$ sudo gem install asautotest

You can also install ASAutotest by simply symlinking the executables into your PATH:

$ ln -s ~/asautotest/bin/asautotest ~/bin
$ ln -s ~/asautotest/bin/flash-policy-server ~/bin

To get started, you need fcsh, which is part of the Flex SDK. It should either be in your PATH, or you can set the FCSH environment variable to the location of the fcsh executable. (Unfortunately, symlinking fcsh into your PATH may not work; if so, you will likely end up preferring to set the environment variable.)

You can find the Flex SDK here: opensource.adobe.com/wiki/display/flexsdk

Usage

Once you have both asautotest and fcsh in place, try this:

$ asautotest ~/my-project/src/main.as

This will compile main.as, using ~/my-project/src as the source directory, and then go to sleep, waiting for changes. As soon as some *.as or *.mxml file in ~/my-project/src (or any subdirectory) changes, ASAutotest will wake up and perform a recompilation.

By default, the resulting SWF is placed in a temporary directory and then thrown away. If you want to use the SWF, you need to specify where it should be placed, using the --output option (or -o for short):

$ cd ~/my-project
$ asautotest src/main.as -o bin/my-project.swf

If you have additional source directores, add them using the --source option (or -I for short):

$ asautotest ~/my-project/src/main.as -I ~/my-other-project/src

To link with SWC files, use the --library option (or -l for short):

$ asautotest main.as -l ../lib/some-library.swc

Autotesting

You can tell ASAutotest to run your SWF as a test using the --test option (or -t for short):

$ asautotest spec.as --test

For this to work, your test must follow a rather complicated protocol involving connecting to a socket and sending the test results in a specific (non-standard) format. ASAutotest comes with adapter code for ASSpec, so if your tests are written using ASSpec, then getting up and running with autotesting should be easy.

Your foo_spec.as should look like this:

package
{
  import asautotest.ASSpecRunner

  public class foo_spec extends ASSpecRunner
  {
    public function foo_spec()
    { super(new FooSuite) }
  }
}

Then you need to add asautotest/assspec/src as a source directory:

$ asautotest foo_spec.as --test -l asspec.swc -I ~/asautotest/asspec/src

Because the test communicates with ASAutotest through a socket, you also need to run a Flash cross-domain policy server on port 843 (which unfortunately requires root privileges); otherwise, the test will not be able to connect to ASAutotest:

$ sudo flash-policy-server

This will just keep running, so you may want to start it in a screen:

$ screen sudo flash-policy-server

You should be all set for autotesting now. Try it out by changing something in your code and watching the tests run automatically. Note that the tests are only executed if all compilations succeed.

Advanced autotesting

By default, ASAutotest expects the test to connect to port 50102. If for some reason you need to use a different port (maybe you have multiple ASAutotest instances running at the same time), you can use the --test-port option to specify it:

$ asautotest foo_spec.as --test --test-port 54321

To change the port that the ASSpec adapter connects to, do this:

public function foo_spec()
{ super(new FooSuite, 54321) }

If you need to write your own adapter to another testing framework, you can use ASSpecRunner.as as a starting point.

Multi-compilation

If you need to compile multiple SWFs (for example, one production SWF and one test), use -- (double hyphen) to divide the command line into sections:

$ asautotest foo.as -o foo.swf -- foo_spec.as --test

This works with any number of source files:

$ asautotest foo.as -- bar.as -- baz.as -- quux.as

Options specified in such a section only apply to that source file. In the following example, only bar.as is linked with asspec.swc and compiled to bar.swf; the other two files are just compiled to check for errors.

$ asautotest foo.as -- bar.as -o bar.swf -l asspec.swc -- baz.as

You can use --- (triple hyphen) to specify global options:

$ asautotest foo.as -o foo.swf -- foo_spec.as --test --- -l asspec.swc

In the above example, both foo.as and foo_spec.as would be linked with asspec.swc.

License

Copyright (C) 2010, 2011 Go Interactive <gointeractive.se/>

This file is part of ASAutotest.

ASAutotest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

ASAutotest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ASAutotest. If not, see <www.gnu.org/licenses/>.