Skip to content

luna() ​

Returns an instance of the class luna

idl
;+
; :Returns: luna
;-
result = luna(routines, $
  _ref_extra = value, $
  bridge_debug_log = value, $
  config_file = value, $
  log_file = value, $
  /no_log, $
  /no_routines, $
  /profile)

Init method for the luna code tester. You are only allowed to call this routine from a main level program so that it will work correctly with sol, the code test runner.

Note: this object can only be created from main level programs.

Examples ​

Create luna at the top of a .spec.pro file, then build the hierarchy luna -> suite -> test -> expectation:

idl
compile_opt idl2

; create luna (main level programs only)
l = luna()

; group related tests in a suite
suite = l.suite('my_routine')

; describe one behavior with a test
it = suite.test('adds two numbers')

; verify the result with an expectation
(it.expects(my_routine(1, 2))).toEqual, 3

; print the results and save logs to disk
l.generateTestSummary

end

Arguments ​

routines ​

optionalinputtype=String | Array<String>

Specify an array of strings that represents the routines that this luna object will be testing. The routines represent the highest priority names in a PRO code file. For example, to specify that we are testing the routines in myawesomeroutine.pro, you would specify 'myawesomeroutine' as the routine name.

This is used for information about things like code coverage, profiling, and validates that the routines can actually be compiled for testing. If this is not specified, then we take an educated guess at the routine being tested based on the file where this is called from.

For example, if we call this from lunadefine.spec.pro then we assume that the routine being tested is lunadefine. The same goes for this being called from lunadefine.pro where we assume the routine is lunadefine.

The reason that you are allowed to specify multiple routines is that, one test suite may be covering all the routines in multiple files and this ensures that all of the code coverage information is tracked for each of those separate files.

Keywords ​

_ref_extra {#kw-_ref_extra} ​

optionalinputtype=any

Specify the keywords VERBOSE, DEBUG, or QUIET on init and the corresponding object properties will be set and carry through to child objects.

bridge_debug_log ​

optionalinputtype=String

If CONFIG_FILE is not set and no idltest.json is found, then you can specify the base name of any file that all debug information will be written to. The file will be generated in IDL's current directory.

config_file ​

optionalinputtype=String

Specify the fully-qualified or relative filepath to a configuration file for your tests (see sol_config). The file must exist. If not set, the idltest.json closest to the test file (in its folder or a parent folder) is used, otherwise default settings apply. You can use / or \\ in the relative paths and it will resolve the location.

log_file ​

optionalinputtype=String

Specify the fully qualified filepath to a file on disk where you want the debug log information to go if you want to override the default behavior. If this file exists on disk, then the contents will be truncated.

no_log ​

optionalinputtype=Boolean

If set, then no log file will be generated.

no_routines ​

optionalinputtype=Boolean

When set, this keyword indicates that there are no routines to check for syntax errors.

profile ​

optionalinputtype=Boolean

If set, then all routines will be watched by the profiler to determine performance information about them.

Licensed under MIT.