Nasal Unit Testing Framework: Difference between revisions

m
Line 3: Line 3:
The intent was to explore the idea of being able to run isolated unit tests against Nasal scripts. The idea was being able to do something like this:
The intent was to explore the idea of being able to run isolated unit tests against Nasal scripts. The idea was being able to do something like this:


=== Concept ===
<pre>
<pre>
standalone-nasal.exe ATR72-FMC-tests.nas
standalone-nasal.exe ATR72-FMC-tests.nas
Line 16: Line 17:
</pre>
</pre>


Based on what I read about the current stand-alone interpreter this should be fairly easy to do.
 
That should now be possible, the nasal-standalone branch builds successfully for Windows, and I ended up with an exe file (see your original thread).
=== The standalone Nasal interpreter ===
Based on what I read about the current stand-alone interpreter this should be fairly easy to do. That should now be possible, the nasal-standalone branch builds successfully for Windows:
 
Here's the Nasal standalone interpreter as part of SimGear: https://gitorious.org/~hooray/fg/hoorays-simgear/commits/topics/nasal-standalone
 
To build it:
<pre>
    cd $SG_SRC
    mkdir BUILD
    cd BUILD
    cmake ../ -DENABLE_TESTS=ON -DSIMGEAR_HEADLESS=ON -DENABLE_SOUND=OFF -D_WIN32=1
    make
</pre>
 
People not using git, can also directly download the source code: https://gitorious.org/fg/hoorays-simgear/archive-tarball/topics/nasal-standalone
(Use 7Zip or IZArc to extract the tarball. Then follow the build instructions (you can also use the cmake GUI for those).
 
Basically
 
*create and use a separate build folder, separate from the source tree
* configure the build via -DENABLE_TESTS=ON -DSIMGEAR_HEADLESS=ON -DENABLE_SOUND=OFF -D_WIN32=1
* build
* report back
 
Let us know if there are still any windows-specific build errors so that we can fix the config file. It should give you a "nasal-bin.exe" in $SG_BUILD/simgear/nasal/ that runs just Nasal scripts, no FG APIs whatsoever.
 
You should be able to "make test" to run a bunch of standard Nasal tests from the original Nasal repository.
 
Okay, I have checked that the build actually works for Windows using the MingW compiler - I am getting a nasal-bin.exe, which I cannot test currently because I don't have a Windows VM available: http://www.speedyshare.com/MbBTA/download/nasal-bin.exe
 
To run it, open a shell (START/EXECUTE cmd/command) and go to the folder of the binary, add a simple Nasal script and run "nasal-bin script.nas"


== Problem ==
== Problem ==