[][src]Function molt::test_harness::test_harness

pub fn test_harness(interp: &mut Interp, args: &[String]) -> Result<(), ()>

Executes the Molt test harness, given the command-line arguments, in the context of the given interpreter.

The first element of the args array must be the name of the test script to execute. The remaining elements are meant to be test harness options, but are currently ignored.

See molt::interp for details on how to configure and add commands to a Molt interpreter.

Example

use molt::Interp;
use std::env;

// FIRST, get the command line arguments.
let args: Vec<String> = env::args().collect();

// NEXT, create and initialize the interpreter.
let mut interp = Interp::new();

// NOTE: commands can be added to the interpreter here.

// NEXT, evaluate the file, if any.
if args.len() > 1 {
    molt::test_harness(&mut interp, &args[1..]);
} else {
    eprintln!("Usage: mytest *filename.tcl");
}