2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-29 05:21:23 +01:00
waf/playground/javatest/wscript

54 lines
1.5 KiB
Python

#! /usr/bin/env python
# encoding: utf-8
# Federico Pellegrin, 2017 (fedepell)
#
# Simple script to demonstrate integration of Java Unit testing inside
# standard waf_unit_test using either TestNG or JUnit
#
def test_results(bld):
"""
Custom post- function that prints out test results.
"""
lst = getattr(bld, 'utest_results', [])
if not lst:
return
for (f, code, out, err) in lst:
print(out.decode('utf-8'))
print(err.decode('utf-8'))
def options(opt):
opt.load('java waf_unit_test javatest')
def configure(conf):
conf.load('java javatest')
def build(bld):
bld(features = 'javac',
name = 'mainprog',
srcdir = 'src/', # folder containing the sources to compile
outdir = 'src', # folder where to output the classes (in the build directory)
sourcepath = ['src'],
basedir = 'src', # folder containing the classes and other files to package (must match outdir)
)
bld(features = 'javac javatest',
srcdir = 'test/', # folder containing the sources to compile
outdir = 'test', # folder where to output the classes (in the build directory)
sourcepath = ['test'],
classpath = [ 'src' ],
basedir = 'test', # folder containing the classes and other files to package (must match outdir)
use = ['JAVATEST', 'mainprog'],
ut_str = 'java -cp ${CLASSPATH} ${JTRUNNER} ${SRC}',
jtest_source = bld.path.ant_glob('test/*.xml'),
# For JUnit do first JUnit configuration and no need to use jtest_source:
# ut_str = 'java -cp ${CLASSPATH} ${JTRUNNER} [TestClass]',
)
bld.add_post_fun(test_results)