This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 45947 - XTest does not interpret test-unit-sys-prop.* properties automatically
Summary: XTest does not interpret test-unit-sys-prop.* properties automatically
Status: CLOSED FIXED
Alias: None
Product: obsolete
Classification: Unclassified
Component: xtest (show other bugs)
Version: 4.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: Jiri Skrivanek
URL:
Keywords:
Depends on:
Blocks: 50156 50165
  Show dependency tree
 
Reported: 2004-07-08 18:17 UTC by Jesse Glick
Modified: 2006-03-24 09:59 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2004-07-08 18:17:23 UTC
I am trying to e.g. get java/project to include
JavaAntLoggerTest when run under XTest. When run
directly this way it works fine:

ant -f java/project/build.xml test

Now the problem. nbproject/project.properties
includes definitions of various system properties
which the unit test needs. XTest does not load them.

I tried to just define xtest.jvm.args, as follows:

xtest.jvm.args=-Dtest.data.dir=${test-unit-sys-prop.test.data.dir}
-Dtest.bridge.jar=${test-unit-sys-prop.test.bridge.jar}
-Dtest.ant.home=${test-unit-sys-prop.test.ant.home}

Unfortunately it is not possible to just reuse the
 same property values as are passed to the regular
build script - the test fails. The reason is that
java/project/test/build-unit.xml loads
project.properties with a basedir of
java/project/test, whereas project.properties
normally assumes that all paths are relative to
java/project. It is not enough to change the
basedir of java/project/test/build-unit.xml to
".." because then nbbuild/templates/xtest-unit.xml
would not succeed in loading
"../nbproject/project.properties".

It is probably already the case that some misc.
properties definable in project.properties, e.g.
${cp.extra}, do not work as intended inside XTest
if you are using relative paths from the module in
them. I have not checked.

Recommendations:

1. All **/test/build-*.xml should set the basedir
to be ".." rather than ".", and
nbbuild/templates/xtest-*.xml should load just
"nbproject/project.properties", so that paths are
evaluated consistently between $module/build.xml
and $module/test/build-$type.xml. xtest-*.xml will
then need to replace

  s!../!!g
  s!..!.!g
  s!(unit|qa-functional)/!test/\1/!g

etc. in some other places in the template, and of
course in any script that overrides any targets.

2. Ideally, automatically look for all properties
of the test-unit-sys-prop.* in Ant and map them to
VM system properties in the test, as
projectized.xml already does, so that it is not
necessary to manually configure this for XTest.
Comment 1 Jesse Glick 2004-07-08 18:21:34 UTC
Workaround is to hack project.properties to assume a different basedir
for XTest than for the regular build, e.g. for java/project:

test-unit-sys-prop.test.data.dir=${basedir}/test/unit/data
test-unit-sys-prop.test.bridge.jar=${ant.dir}/ant/nblib/bridge.jar
test-unit-sys-prop.test.ant.home=${ant.dir}/ant
xtest.jvm.args=-Dtest.data.dir=${basedir}/unit/data
-Dtest.bridge.jar=${test-unit-sys-prop.test.bridge.jar}
-Dtest.ant.home=${test-unit-sys-prop.test.ant.home}

Note the different definitions of test.data.dir. The other two are
unaffected since ${ant.dir} is an absolute path which xtest-unit.xml
seems to set correctly.
Comment 2 Jesse Glick 2004-09-21 20:21:43 UTC
Any plans?
Comment 3 Jiri Skrivanek 2004-09-24 14:18:37 UTC
I am looking at it. I will update soon.
Comment 4 Jiri Skrivanek 2004-09-27 14:43:03 UTC
1. I think that it is not needed to use complicated things to resolve
all paths. It is easy to replace relative path by absolute one and for
the future assure that properties intended for xtest have to use
absolute paths. Please, replace ${basedir}/test/unit/data by
${nb_all}/java/project/test/unit/data.

2. Properties of the test-unit-sys-prop.* are mapped to system
properties in xtest-unit.xml.

/cvs/nbbuild/templates/xtest-unit.xml,v  <--  xtest-unit.xml
new revision: 1.6; previous revision: 1.5
Comment 5 Jesse Glick 2004-10-08 17:47:05 UTC
Re. #1 - ${basedir} *is* an absolute path. It just seems to me that
all scripts reading the same properties file should be using the same
basedir. But the workaround with ${nb_all} works.

#2 works. Used in all modules I could find that had the workaround:

committed   * Up-To-Date  1.8        
ant/grammar/nbproject/project.properties
committed   * Up-To-Date  1.13        ant/nbproject/project.properties
committed   * Up-To-Date  1.8        
apisupport/project/nbproject/project.properties
committed   * Up-To-Date  1.8        
java/project/nbproject/project.properties
committed   * Up-To-Date  1.9        
web/ddapi/nbproject/project.properties