Nice/src/nice/tools/testsuite runner.nice,NONE,1.1

Daniel Bonniot <[email protected]> Mon, 11 Apr 2005 12:45:38 +0000
Newsgroups gmane.comp.lang.nice.cvs
Message-ID <[email protected]>
Update of /cvsroot/nice/Nice/src/nice/tools/testsuite
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24733/src/nice/tools/testsuite

Added Files:
	runner.nice 
Log Message:
Embedded DSL to write testcases as nice programs calling the compiler.


--- NEW FILE: runner.nice ---
/**************************************************************************/
/*                                N I C E                                 */
/*             A high-level object-oriented research language             */
/*                        (c) Daniel Bonniot 2005                         */
/*                                                                        */
/*  This program 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 2 of the License, or     */
/*  (at your option) any later version.                                   */
/*                                                                        */
/**************************************************************************/

package nice.tools.testsuite;

/**
   Runner for the testsuite Embedded-DSL.

   @author Daniel Bonniot ([email protected])
 */

import nice.io;
import nice.functional;

import nice.tools.compiler.console;
import nice.tools.compiler;
import bossa.modules;

import nice.tools.unit.console;
import nice.tools.unit;

import java.io.*;

let File tmp = new File("temp-testcase");

public void main(String[] args)
{
  let dir = new File(args.length == 0 ? "testsuite" : args[0]);
  dir.traverse().foreach(File f =>
    if (f.isDirectory() && f.hasNiceFile())
      test(f));
}

boolean hasNiceFile(File dir) =
  dir.listDir(File f => f.getPath().endsWith(".nice")).length > 0;

void test(File f)
{
  let pkg = f.getPath().replace(File.separatorChar, '.');

  println("\nCompiling "pkg);

  let output = consoleOutput();
  let compilation = new bossa.modules.Compilation
    (listener: output, parser: new bossa.parser.JavaccParser());
  compilation.runtimeFile = "share/java/nice.jar";
  compilation.output = new File(tmp, "test.jar").toString();

  compile(compilation, pkg);

  if (output.errorCount > 0)
    return;

  println("\nTesting "pkg);
  let testListener = new nice.tools.unit.console.Listener();
  runTests(pkg, testListener, new File(tmp, "test.jar") + File.pathSeparator + "classes");
}



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click