Testing IDL and ENVI Code
Preview
Testing and the related agent skills are a preview feature. They work, but we are still refining them. Please share feedback and issues on GitHub.
Sol and Luna are a modern testing framework for IDL, inspired by test frameworks from the JavaScript/TypeScript world.
- Luna is the framework you use to write tests (
luna()) - Sol is the runner that finds your tests, executes them, and summarizes the results (
sol())
With them you can:
- Automate unit tests for IDL, ENVI, or IDL + ENVI code with a simple pass/fail result
- Write tests that describe themselves, so test names say what the code should do
- Generate logs that show what passed and failed, with line numbers for errors
- Collect code coverage and IDL profiler statistics with a single configuration option
Why does the extension include this?
We want agents to write the best code possible, and that includes creating and running tests. When IDL Agent has a way to check its own work, it can find and fix problems before you ever see the code.
Tests are just as useful when you write code yourself, so everything here works with or without an agent.
What You Get
| Page | Description |
|---|---|
| Setup | Create idlpackage.json, idlformat.json, and idltest.json with commands or an agent |
| Writing tests | Spec files, suites, and expectations |
| Running tests | Run one test or the whole suite, read the output, and create reports |
| Configuration | Everything you can control from idltest.json |
| Formatting | Auto-indent and style tests just like PRO code when using our formatter |
| API reference | Generated docs for Sol and Luna classes and routines |
Quick Example
Next to my_routine.pro, create my_routine.spec.pro:
compile_opt idl2
l = luna()
s = l.suite('my_routine')
it = s.test('runs without errors')
(it.expects('my_routine')).toRunProcedure
l.generateTestSummary
endCompile and run the file and you will see a summary like this:
Test file: src/my_routine.spec.pro
my_routine
runs without errors
expected to run procedure (0.00 s, line 9)
PASS
Tests: 1 passed, 1 total
Time: 0.1 sGet Help from an Agent
IDL Agent includes skills that know how to set up, write, and run tests. Try asking:
- "Set up this folder as an IDL package with tests"
- "Write tests for
my_routine" - "Run the tests and tell me why they fail"
Learn more about the skills in Setup.