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.

View | Details | Raw Unified | Return to bug 54161
Collapse All | Expand All

(-)templates/projectized.xml (-11 / +21 lines)
Line 30 Link Here
30
        <property name="test.dist.dir" location="${nb_all}/nbbuild/build/testdist"/>
31
Lines 32-41 Link Here
32
            project="."
34
                project="."
33
            publicpackagesproperty="public.packages"
35
                publicpackagesproperty="public.packages"
34
            friendsproperty="friends"
36
                friendsproperty="friends"
35
            javadocpackagesproperty="module.javadoc.packages"
37
                javadocpackagesproperty="module.javadoc.packages"
36
            moduledependenciesproperty="module.dependencies"
38
                moduledependenciesproperty="module.dependencies"
37
            moduleclasspathproperty="module.classpath"
39
                moduleclasspathproperty="module.classpath"
38
            publicpackagejardir="${public.package.jar.dir}"
40
                publicpackagejardir="${public.package.jar.dir}"
39
            modulerunclasspathproperty="module.run.classpath"
41
                modulerunclasspathproperty="module.run.classpath"
40
            domainproperty="nbm.domain"
42
                domainproperty="nbm.domain"
41
            classpathextensionsproperty="class.path.extensions"/>
43
                classpathextensionsproperty="class.path.extensions">
42
--
44
            <testtype name="unit" 
45
                      folder="test.unit.folder" 
46
                      runtimecp="test.unit.runtime.cp" 
47
                      compilecp="test.unit.compile.cp"/>
48
            <testtype name="qa-functional" 
49
                      folder="test.qa-functional.folder" 
50
                      runtimecp="test.qa-functional.runtime.cp" 
51
                      compilecp="test.qa-functional.compile.cp"/>         
52
        </parseprojectxml>
(-)templates/common.xml (-14 / +137 lines)
Line 303 Link Here
303
304
        <property name="test.qa-functional.dir" location="test/qa-functional"/>
305
        <property name="test.qa-functional.src.dir" location="${test.qa-functional.dir}/src"/>
306
        <property name="build.test.qa-functional.dir" location="build/test/qa-functional"/>
307
        <property name="build.test.qa-functional.classes.dir" location="${build.test.qa-functional.dir}/classes"/>
308
        <property name="build.test.qa-functional.results.dir" location="${build.test.qa-functional.dir}/results"/>
309
        
Line 306 Link Here
306
            <pathelement path="${module.run.classpath}"/>
313
            <pathelement path="${test.unit.compile.cp}"/>
307
--
Line 313 Link Here
313
            <path refid="test.unit.cp"/>
320
            <!-- Cannot use <path refid="cp"/> since that uses ${module.classpath} and we want ${module.run.classpath}: -->
314
--
321
            <pathelement path="${test.unit.runtime.cp}"/>
322
            <pathelement path="${cp.extra}"/>
323
            <pathelement location="${cluster}/${module.jar}"/>
324
            <path refid="test.unit.lib.cp"/>
325
            <pathelement path="${test.unit.cp.extra}"/>
326
            <pathelement path="${build.test.unit.classes.dir}"/>
327
        </path>
328
        
329
        <!-- path reference used in both compiler and executor -->
330
        <path id="test.qa-functional.cp">
331
            <!-- Cannot use <path refid="cp"/> since that uses ${module.classpath} and we want ${module.run.classpath}: -->
332
            <pathelement path="${test.qa-functional.compile.cp}"/>
333
            <pathelement path="${cp.extra}"/>
334
            <pathelement location="${cluster}/${module.jar}"/>
335
            <path refid="test.unit.lib.cp"/>
336
            <pathelement path="${test.qa-functional.cp.extra}"/>
337
            <pathelement path="${nb_all}/jellytools/builds/jelly2-nb.jar"/>
338
            <pathelement location="${nb_all}/jemmy/builds/jemmy.jar"/>
339
        </path>
340
        <path id="test.qa-functional.run.cp">
341
            <pathelement path="${test.qa-functional.runtime.cp}"/>
Line 315 Link Here
315
            <pathelement path="${test.unit.run.cp.extra}"/>
343
            <path refid="test.unit.lib.cp"/>
316
--
344
            <pathelement path="${test.qa-functional.run.cp.extra}"/>
Line 323 Link Here
323
    <target name="test-build" depends="jar,do-test-build"/>
352
    <target name="test-build" depends="jar,do-test-build,test-build-datajar"/>
324
--
Line 348 Link Here
377
        
378
        <available file="${test.unit.dir}/data" type="dir" property="exists.test.data"/>
379
        <!-- test distribution -->
380
               <mkdir dir="${nb_all}/nbbuild/build/testdist"/>
381
               <property name="test.dist.dir" location="${nb_all}/nbbuild/build/testdist"/>
382
               <mkdir dir="${test.dist.dir}/extralibs"/>
383
               <property name="extra.test.libs.dir" location="${test.dist.dir}/extralibs"/> 
384
           <property name="test.unit.out.folder" location="${test.unit.folder}"/>
385
           <mkdir dir="${test.unit.out.folder}"/>
386
           <jar destfile="${test.unit.out.folder}/tests.jar" basedir="${build.test.unit.classes.dir}"/>            
387
           <!-- create properties -->
388
           <taskdef name="shorterpaths" classname="org.netbeans.nbbuild.ShorterPaths" classpath="${nb_all}/nbbuild/nbantext.jar"/>
389
            <shorterpaths inref="test.unit.run.cp" 
390
                           out="test.unit.run.cp.short" 
391
                           extralibs="extra.test.libs.short" 
392
                           extralibsdir="${extra.test.libs.dir}"
393
                           testproperties="${test.unit.out.folder}/test.properties">
394
395
                <replacement dir="${netbeans.dest.dir}" name="netbeans.dest.dir"/>
396
                <replacement dir="${test.dist.dir}" name="test.dist.dir"/>
397
                <replacement dir="${java.home}" name="java.home"/>
398
                <replacement dir="${java.home.parent}" name="java.home.parent"/>
399
            </shorterpaths>
400
            <copy file="${nb_all}/nbbuild/templates/testdist/unit-unit.xml" tofile="${test.unit.out.folder}/unit-unit.xml"/>
401
             <copy todir="${test.unit.out.folder}">
402
                <fileset dir="${test.unit.dir}/..">
403
                  <include name="build-unit.xml"/>
404
                  <include name="build.xml"/>
405
                  <include name="cfg-unit.xml"/>
406
                </fileset>
407
            </copy>
408
    </target>
409
    
410
    <target name="test-build-datajar" depends="do-test-build" if="exists.test.data">
411
           <zip destfile="${test.unit.out.folder}/data.zip" basedir="${test.unit.dir}/data"/> 
Line 350 Link Here
414
415
    <target name="test-build-qa-functional" depends="jar,do-test-build-qa-functional,test-build-datajar-qa-functional"/>
416
        
417
418
    <target name="do-test-build-qa-functional" depends="init,test-init">
419
        <mkdir dir="${build.test.qa-functional.classes.dir}"/>
420
        <javac srcdir="${test.qa-functional.src.dir}" destdir="${build.test.qa-functional.classes.dir}"
421
               debug="true" deprecation="${build.compiler.deprecation}"
422
               source="${javac.source}" target="${javac.target}" optimize="${build.compiler.optimize}" includeantruntime="false">
423
               <exclude name="**/jars/**"/><!-- XXX for core only; fix in core, not here -->
424
               <exclude name="**/data/**"/><!-- XXX for openide/util and co. -->
425
            <classpath refid="test.qa-functional.cp"/>
426
            <compilerarg line="${javac.compilerargs}"/>
427
        </javac>
428
        <copy todir="${build.test.qa-functional.classes.dir}">
429
            <fileset dir="${test.qa-functional.src.dir}">
430
                <exclude name="**/*.java"/>
431
            </fileset>
432
        </copy>
433
        <copy todir="${build.test.qa-functional.dir}">
434
            <fileset dir="${test.qa-functional.dir}">
435
                <include name="data/**"/>
436
            </fileset>
437
        </copy>
438
        
439
        <available file="${test.qa-functional.dir}/data" type="dir" property="exists.test.qa-functional.data"/>
440
        <!-- test distribution -->
441
               <mkdir dir="${nb_all}/nbbuild/build/testdist"/>
442
               <property name="test.dist.dir" location="${nb_all}/nbbuild/build/testdist"/>
443
               <mkdir dir="${test.dist.dir}/extralibs"/>
444
               <property name="extra.test.libs.dir" location="${test.dist.dir}/extralibs"/> 
445
           <property name="test.qa-functional.out.folder" location="${test.qa-functional.folder}"/>
446
           <mkdir dir="${test.qa-functional.out.folder}"/>
447
           <jar destfile="${test.qa-functional.out.folder}/tests.jar" basedir="${build.test.qa-functional.classes.dir}"/>            
448
           <!-- create properties -->
449
           <taskdef name="shorterpaths" classname="org.netbeans.nbbuild.ShorterPaths" classpath="${nb_all}/nbbuild/nbantext.jar"/>
450
            <shorterpaths inref="test.qa-functional.run.cp" 
451
                           out="test.qa-functional.run.cp.short" 
452
                           extralibs="extra.test.libs.short" 
453
                           extralibsdir="${extra.test.libs.dir}"
454
                           testproperties="${test.qa-functional.out.folder}/test.properties">
455
456
                <replacement dir="${netbeans.dest.dir}" name="netbeans.dest.dir"/>
457
                <replacement dir="${test.dist.dir}" name="test.dist.dir"/>
458
                <replacement dir="${java.home}" name="java.home"/>
459
                <replacement dir="${java.home.parent}" name="java.home.parent"/>
460
            </shorterpaths>
461
             <copy todir="${test.qa-functional.out.folder}">
462
                <fileset dir="${test.qa-functional.dir}/..">
463
                  <include name="build-qa-functional.xml"/>
464
                  <include name="build.xml"/>
465
                  <include name="cfg-qa-functional.xml"/>
466
                </fileset>
467
            </copy>
468
    </target>
469
    
470
    <target name="test-build-datajar-qa-functional" depends="do-test-build-qa-functional" if="exists.test.qa-functional.data">
471
           <zip destfile="${test.qa-functional.out.folder}/data.zip" basedir="${test.qa-functional.dir}/data"/> 
472
    </target>
473
    
474
    
Lines 380-381 Link Here
380
                <fileset dir="${test.unit.src.dir}">
505
                <fileset dir="${build.test.unit.classes.dir}">
381
                    <include name="**/*Test.java"/>
506
                    <include name="**/*Test.class"/>
382
--
Line 386 Link Here
386
            <!-- <assertions> does not seem to work in Ant 1.6.1? -->
Line 582 Link Here
582
706
    
583
--
707
    <target name="fix-test-dependencies" depends="basic-init" description="It moves classpath for tests from project.properties to project.xml.">
708
           <taskdef name="fix-test-deps" classname="org.netbeans.nbbuild.FixTestDependencies" classpath="${nb_all}/nbbuild/nbantext.jar"/>
709
            <fix-test-deps projectXml="nbproject/project.xml" 
710
                  propertiesFile="nbproject/project.properties"/>  
711
    </target>
(-)antsrc/org/netbeans/nbbuild/ParseProjectXml.java (-4 / +321 lines)
Line 31 Link Here
31
import java.util.HashMap;
Line 34 Link Here
35
import java.util.LinkedList;
Line 35 Link Here
37
import java.util.Map;
Line 192 Link Here
195
    // test distribution path 
196
    public  static String testDistLocation;
197
198
    public static class TestType {
199
        private String name;
200
        private String folder;
201
        private String runtimeCP;
202
        private String compileCP;
203
204
        public TestType() {}
205
        public String getName() {
206
            return name;
207
        }
208
209
        public void setName(String name) {
210
            this.name = name;
211
        }
212
213
        public String getFolder() {
214
            return folder;
215
        }
216
217
        public void setFolder(String folder) {
218
            this.folder = folder;
219
        }
220
221
        public String getRuntimeCP() {
222
            return runtimeCP;
223
        }
224
225
        public void setRuntimeCP(String runtimeCP) {
226
            this.runtimeCP = runtimeCP;
227
        }
228
229
        public String getCompileCP() {
230
            return compileCP;
231
        }
232
233
        public void setCompileCP(String compileCP) {
234
            this.compileCP = compileCP;
235
        }
236
        
237
    }
238
      List /*<TestType>*/ testTypes = new LinkedList();
239
      
240
      public void addTestType(TestType testType) {
241
          testTypes.add(testType);
242
      }
243
      public void add(TestType testType) {
244
          testTypes.add(testType);
245
      }
246
  
247
      
248
      private TestType getTestType(String name) {
249
          for (int i = 0 ; i < testTypes.size() ; i++) {
250
              TestType testType = (TestType) testTypes.get(i);
251
              if (testType.getName().equals(name)) {
252
                  return testType;
253
              }
254
          }
255
          return null;
256
      }
257
//    // unitest properties
258
//    //
259
//    private String unitTestFolderProperty ;
260
//    private String unitTestCompileClassPathProperty;
261
//    private String unitTestRuntimeClassPathProperty;
262
//
263
//    public void setUnitTestFolderProperty(String unitTestFolder) {
264
//        this.unitTestFolderProperty = unitTestFolder;
265
//    }
266
//
267
//    public void setUnitTestCompileClassPathProperty(String unitTestCompileClassPathProperty) {
268
//        this.unitTestCompileClassPathProperty = unitTestCompileClassPathProperty;
269
//    }
270
//
271
//    public void setUnitTestRuntimeClassPathProperty(String unitTestRuntimeClassPathProperty) {
272
//        this.unitTestRuntimeClassPathProperty = unitTestRuntimeClassPathProperty;
273
//    }
274
//
275
//
276
//    // qa-functional tests properties
277
//    //
278
//    private String qaFunctionalTestFolderProperty ;
279
//    private String qaFunctionalTestCompileClassPathProperty;
280
//    private String qaFunctionalTestRuntimeClassPathProperty;
281
//
282
//    public void setQaFunctionalTestFolderProperty(String qaFunctionalTestFolder) {
283
//        this.qaFunctionalTestFolderProperty = qaFunctionalTestFolder;
284
//    }
285
//
286
//    public void setQaFunctionalTestCompileClassPathProperty(String qaFunctionalTestCompileClassPathProperty) {
287
//        this.qaFunctionalTestCompileClassPathProperty = qaFunctionalTestCompileClassPathProperty;
288
//    }
289
//
290
//    public void setQaFunctionalTestRuntimeClassPathProperty(String qaFunctionalTestRuntimeClassPathProperty) {
291
//        this.qaFunctionalTestRuntimeClassPathProperty = qaFunctionalTestRuntimeClassPathProperty;
292
//    }
293
//
294
 
295
296
 
Line 201 Link Here
306
    
Line 279 Link Here
279
            if (moduleDependenciesProperty != null || moduleClassPathProperty != null || moduleRunClassPathProperty != null) {
385
            if (moduleDependenciesProperty != null || 
280
--
386
                    moduleClassPathProperty != null || 
387
                    moduleRunClassPathProperty != null ||
388
                    testTypes.size() > 0) {
Line 351 Link Here
460
            
461
            // Test dependecies
462
            //
463
            if (modules != null) {
464
               String testDistLocation = getProject().getProperty(TestDeps.TEST_DIST_VAR);
465
               if (testDistLocation == null) {
466
                   testDistLocation = "${" + TestDeps.TEST_DIST_VAR + "}";
467
               }
468
               ParseProjectXml.testDistLocation = testDistLocation;
469
               
470
                TestDeps testDepss[] = getTestDeps(pDoc,modules,getCodeNameBase(pDoc));
471
                for (int tdIt = 0 ; tdIt < testDepss.length ; tdIt++) {
472
                    TestDeps td = testDepss[tdIt];
473
                    // unit tests 
474
                    TestType testType = getTestType(td.testtype);
475
                    if (testType!= null ) {
476
                        if (testType.getFolder() != null) {
477
                            define (testType.getFolder(),td.getTestFolder());
478
                        }
479
                        if (testType.getCompileCP() != null) {
480
                            
481
                            define(testType.getCompileCP(),td.getCompileClassPath());
482
                        }
483
                        if (testType.getRuntimeCP() != null) {
484
                            define(testType.getRuntimeCP(),td.getRuntimeClassPath());
485
                        }
486
487
                    } 
488
                }
489
            }
Line 740 Link Here
740
    
879
 
741
--
880
  final class TestDeps {
881
      public static final String UNIT = "unit";
882
      public static final String QA_FUNCTIONAL = "qa-functional";
883
      // unit, qa-functional, performance
884
      final String testtype;
885
      // all dependecies for the testtype
886
      final  List /*<TestDep>*/ dependencies = new ArrayList();
887
      // code name base of tested module
888
      final String cnb;
889
      final ModuleListParser modulesParser;
890
891
      public  static final String TEST_DIST_VAR = "test.dist.dir";
892
      public TestDeps(String testtype,String cnb,ModuleListParser modulesParser) {
893
          assert modulesParser != null;
894
          this.testtype = testtype;
895
          this.cnb = cnb;
896
          this.modulesParser = modulesParser;
897
      }
898
      
899
      public List/*<String>*/ getFiles(boolean compile) {
900
          List/*<String>*/ files = new ArrayList();
901
          for (int dIt = 0 ; dIt < dependencies.size() ; dIt++) {
902
              files.addAll(((TestDep)dependencies.get(dIt)).getFiles(compile));
903
          }
904
          return files;
905
      }
906
      public void addDepenency(TestDep dep) {
907
          dependencies.add(dep);
908
      }
909
910
        private String getTestFolder() {
911
            ModuleListParser.Entry entry = modulesParser.findByCodeNameBase(cnb);
912
            String sep = File.separator;
913
            return ParseProjectXml.testDistLocation + sep + testtype + sep + entry.getClusterName() + sep + cnb.replace('.','-');
914
        }
915
916
        String getCompileClassPath() {
917
            return getPath(getFiles(true));
918
        }
919
        private String getPath(List/*<String>*/ files) {
920
            StringBuffer path = new StringBuffer();
921
            Set/*<String>*/ filesSet = new HashSet();
922
            for (int fIt = 0 ; fIt < files.size() ; fIt++) {
923
                String filePath = (String)files.get(fIt);
924
                if (!filesSet.contains(filePath)) {
925
                    if (path.length() > 0) {
926
                        path.append(File.pathSeparatorChar);
927
                    } 
928
                    filesSet.add(filePath);
929
                    path.append(filePath);
930
                }
931
            }
932
            return path.toString();    
933
        }
934
935
        String getRuntimeClassPath() {
936
            return getPath(getFiles(false));
937
        }
938
        
939
940
  }
941
   /** Test dependency for module and type
942
    */ 
943
   final class TestDep {
944
       final ModuleListParser modulesParser;
945
       // code name base
946
       final String cnb;
947
       // dependencies on tests of modules
948
       final boolean recursive;
949
       final boolean test;
950
       // runtime classpath
951
       final boolean compile;
952
       TestDeps testDeps;
953
       
954
       TestDep (String cnb,ModuleListParser modules, boolean recursive,boolean test, boolean compile,TestDeps testDeps) {   
955
           this.modulesParser = modules;
956
           this.cnb = cnb;
957
           this.recursive = recursive;
958
           this.test = test;
959
           this.testDeps = testDeps;
960
           this.compile = compile;
961
       }
962
       /* get modules dependecies
963
        */
964
       List/*<ModuleListParser.Entry>*/ getModules() {
965
           List /*<ModuleListParser.Entry>*/ entries = new ArrayList();
966
           if (!test) {
967
               if (recursive ) {
968
                   Map/*<String,ModuleListParser.Entry>*/ entriesMap = new HashMap();
969
                   addRecursiveModules(cnb,entriesMap);
970
                   entries.addAll(entriesMap.values());
971
               } else {
972
                   entries.add(modulesParser.findByCodeNameBase(cnb));
973
               }
974
           }
975
           return entries;     
976
           
977
       } 
978
       
979
       private void addRecursiveModules(String cnd, Map entriesMap) {
980
           if (!entriesMap.containsKey(cnd)) {
981
               ModuleListParser.Entry entry = modulesParser.findByCodeNameBase(cnd);
982
               entriesMap.put(cnd,entry);
983
               String cnds[] = entry.getBuildPrerequisites();
984
               // cnds can be null
985
               if (cnds != null) {
986
                   for (int i = 0 ; i < cnds.length ; i++) {
987
                       addRecursiveModules(cnds[i],entriesMap);
988
                   }
989
               }
990
           }
991
       }
992
       List/*<String>*/ getFiles(boolean compile) {
993
           List/*<String>*/ files = new ArrayList();
994
           if (!compile ||  ( compile && this.compile)) {
995
               List /*<ModuleListParser.Entry>*/ modules = getModules();  
996
               for (int mIt = 0 ; mIt <modules.size() ; mIt++) {
997
                   ModuleListParser.Entry entry = (ModuleListParser.Entry)modules.get(mIt);
998
                   if (entry != null) {
999
                       files.add(entry.getJar().getAbsolutePath());
1000
                   } else {
1001
                       log("Entry doesn't exist.");
1002
                   }
1003
               }
1004
               // get tests files
1005
               if (test) {
1006
                   // get test folder
1007
                   ModuleListParser.Entry entry = (ModuleListParser.Entry) modulesParser.findByCodeNameBase(cnb);
1008
                   String sep = File.separator;
1009
                   String jarPath = ParseProjectXml.testDistLocation + sep + testDeps.testtype + sep +  entry.getClusterName() + sep + cnb.replace('.','-') + sep + "tests.jar";
1010
                   files.add(jarPath);
1011
               }
1012
           }
1013
           return files;
1014
       }
1015
   } 
Line 850 Link Here
1125
    private TestDeps[] getTestDeps(Document pDoc,ModuleListParser modules,String testCnb) {
1126
        assert modules != null;
1127
        Element cfg = getConfig(pDoc);
1128
        List testDepsList = new ArrayList(); 
1129
        Element pp = XMLUtil.findElement(cfg, "test-dependencies", NBM_NS);
1130
        if (pp != null) {
1131
            for (Iterator depssIt = XMLUtil.findSubElements(pp).iterator(); depssIt.hasNext();) {
1132
                Element depssEl = (Element) depssIt.next();
1133
                String testType = findTextOrNull(depssEl,"name");
1134
                if (testType == null) {
1135
                    testType = TestDeps.UNIT; // default variant
1136
                }
1137
                TestDeps testDeps = new TestDeps(testType,testCnb,modules);
1138
                testDepsList.add(testDeps);
1139
                for (Iterator depsIt = XMLUtil.findSubElements(depssEl).iterator() ; depsIt.hasNext();) {
1140
                    Element el = (Element) depsIt.next();
1141
                    if (el.getTagName().equals("test-dependency")) {
1142
                        // parse test dep
1143
                        boolean  test =   (XMLUtil.findElement(el,"test",NBM_NS) != null);;
1144
                        String cnb =  findTextOrNull(el,"code-name-base");
1145
                        boolean  recursive = (XMLUtil.findElement(el,"recursive",NBM_NS) != null);
1146
                        boolean  compile = (XMLUtil.findElement(el,"compile-dependency",NBM_NS) != null);                    
1147
                        testDeps.addDepenency(new TestDep(cnb,
1148
                                                         modules,
1149
                                                         recursive,
1150
                                                         test,
1151
                                                         compile,
1152
                                                         testDeps)); 
1153
                    }
1154
1155
                }
1156
            }
1157
        }
1158
        TestDeps testDepss[] = new TestDeps[testDepsList.size()];
1159
        testDepsList.toArray(testDepss);
1160
        return testDepss;      
1161
    }
1162
    private static String findTextOrNull(Element parentElement,String elementName) {
1163
        Element el = XMLUtil.findElement(parentElement,elementName,NBM_NS);
1164
        return (el == null) ? null :
1165
                              XMLUtil.findText(el);
1166
                
1167
    }
1168
 

Return to bug 54161