Lines 475-487
Link Here
|
475 |
if (targetNames == null) { |
475 |
if (targetNames == null) { |
476 |
return; |
476 |
return; |
477 |
} |
477 |
} |
|
|
478 |
final String command2execute; |
479 |
if(COMMAND_TEST_SINGLE.equals(command) && targetNames.length == 1 && targetNames[0].equals(COMMAND_TEST)) { |
480 |
//multiple files or package(s) selected so we need to call test target instead of test-single |
481 |
command2execute = COMMAND_TEST; |
482 |
p.put("nb.internal.action.name", command2execute); |
483 |
} else { |
484 |
command2execute = command; |
485 |
} |
478 |
if (isCompileOnSaveEnabled) { |
486 |
if (isCompileOnSaveEnabled) { |
479 |
if (COMMAND_BUILD.equals(command) && !allowAntBuild()) { |
487 |
if (COMMAND_BUILD.equals(command2execute) && !allowAntBuild()) { |
480 |
showBuildActionWarning(context); |
488 |
showBuildActionWarning(context); |
481 |
return ; |
489 |
return ; |
482 |
} |
490 |
} |
483 |
Map<String, Object> execProperties = new HashMap<String, Object>(); |
491 |
Map<String, Object> execProperties = new HashMap<String, Object>(); |
484 |
execProperties.put("nb.internal.action.name", command); |
492 |
execProperties.put("nb.internal.action.name", command2execute); |
485 |
|
493 |
|
486 |
copyMultiValue(ProjectProperties.RUN_JVM_ARGS, execProperties); |
494 |
copyMultiValue(ProjectProperties.RUN_JVM_ARGS, execProperties); |
487 |
prepareWorkDir(execProperties); |
495 |
prepareWorkDir(execProperties); |
Lines 508-514
Link Here
|
508 |
String url = p.getProperty("applet.url"); |
516 |
String url = p.getProperty("applet.url"); |
509 |
execProperties.put("applet.url", url); |
517 |
execProperties.put("applet.url", url); |
510 |
execProperties.put(JavaRunner.PROP_EXECUTE_FILE, file); |
518 |
execProperties.put(JavaRunner.PROP_EXECUTE_FILE, file); |
511 |
prepareSystemProperties(execProperties, command, context, false); |
519 |
prepareSystemProperties(execProperties, command2execute, context, false); |
512 |
task = |
520 |
task = |
513 |
JavaRunner.execute(targetNames[0], execProperties); |
521 |
JavaRunner.execute(targetNames[0], execProperties); |
514 |
} |
522 |
} |
Lines 517-566
Link Here
|
517 |
} |
525 |
} |
518 |
return; |
526 |
return; |
519 |
} |
527 |
} |
520 |
if (!isServerExecution() && (COMMAND_RUN.equals(command) || COMMAND_DEBUG.equals(command) || COMMAND_DEBUG_STEP_INTO.equals(command) || COMMAND_PROFILE.equals(command))) { |
528 |
if (!isServerExecution() && (COMMAND_RUN.equals(command2execute) || COMMAND_DEBUG.equals(command2execute) || COMMAND_DEBUG_STEP_INTO.equals(command2execute) || COMMAND_PROFILE.equals(command2execute))) { |
521 |
prepareSystemProperties(execProperties, command, context, false); |
529 |
prepareSystemProperties(execProperties, command2execute, context, false); |
522 |
AtomicReference<ExecutorTask> _task = new AtomicReference<ExecutorTask>(); |
530 |
AtomicReference<ExecutorTask> _task = new AtomicReference<ExecutorTask>(); |
523 |
bypassAntBuildScript(command, context, execProperties, _task); |
531 |
bypassAntBuildScript(command2execute, context, execProperties, _task); |
524 |
task = _task.get(); |
532 |
task = _task.get(); |
525 |
return ; |
533 |
return ; |
526 |
} |
534 |
} |
527 |
// for example RUN_SINGLE Java file with Servlet must be run on server and not locally |
535 |
// for example RUN_SINGLE Java file with Servlet must be run on server and not locally |
528 |
boolean serverExecution = p.getProperty(PROPERTY_RUN_SINGLE_ON_SERVER) != null; |
536 |
boolean serverExecution = p.getProperty(PROPERTY_RUN_SINGLE_ON_SERVER) != null; |
529 |
p.remove(PROPERTY_RUN_SINGLE_ON_SERVER); |
537 |
p.remove(PROPERTY_RUN_SINGLE_ON_SERVER); |
530 |
if (!serverExecution && (COMMAND_RUN_SINGLE.equals(command) || COMMAND_DEBUG_SINGLE.equals(command) || COMMAND_PROFILE_SINGLE.equals(command))) { |
538 |
if (!serverExecution && (COMMAND_RUN_SINGLE.equals(command2execute) || COMMAND_DEBUG_SINGLE.equals(command2execute) || COMMAND_PROFILE_SINGLE.equals(command2execute))) { |
531 |
prepareSystemProperties(execProperties, command, context, false); |
539 |
prepareSystemProperties(execProperties, command2execute, context, false); |
532 |
if (COMMAND_RUN_SINGLE.equals(command)) { |
540 |
if (COMMAND_RUN_SINGLE.equals(command2execute)) { |
533 |
execProperties.put(JavaRunner.PROP_CLASSNAME, p.getProperty("run.class")); |
541 |
execProperties.put(JavaRunner.PROP_CLASSNAME, p.getProperty("run.class")); |
534 |
} else if (COMMAND_DEBUG_SINGLE.equals(command)) { |
542 |
} else if (COMMAND_DEBUG_SINGLE.equals(command2execute)) { |
535 |
execProperties.put(JavaRunner.PROP_CLASSNAME, p.getProperty("debug.class")); |
543 |
execProperties.put(JavaRunner.PROP_CLASSNAME, p.getProperty("debug.class")); |
536 |
} else { |
544 |
} else { |
537 |
execProperties.put(JavaRunner.PROP_CLASSNAME, p.getProperty("profile.class")); |
545 |
execProperties.put(JavaRunner.PROP_CLASSNAME, p.getProperty("profile.class")); |
538 |
} |
546 |
} |
539 |
AtomicReference<ExecutorTask> _task = new AtomicReference<ExecutorTask>(); |
547 |
AtomicReference<ExecutorTask> _task = new AtomicReference<ExecutorTask>(); |
540 |
bypassAntBuildScript(command, context, execProperties, _task); |
548 |
bypassAntBuildScript(command2execute, context, execProperties, _task); |
541 |
task = _task.get(); |
549 |
task = _task.get(); |
542 |
return; |
550 |
return; |
543 |
} |
551 |
} |
544 |
String buildDir = evaluator.getProperty(ProjectProperties.BUILD_DIR); |
552 |
String buildDir = evaluator.getProperty(ProjectProperties.BUILD_DIR); |
545 |
if (COMMAND_TEST_SINGLE.equals(command) || COMMAND_DEBUG_TEST_SINGLE.equals(command) || COMMAND_PROFILE_TEST_SINGLE.equals(command)) { |
553 |
if (COMMAND_TEST_SINGLE.equals(command2execute) || COMMAND_DEBUG_TEST_SINGLE.equals(command2execute) || COMMAND_PROFILE_TEST_SINGLE.equals(command2execute)) { |
546 |
@SuppressWarnings("MismatchedReadAndWriteOfArray") |
554 |
@SuppressWarnings("MismatchedReadAndWriteOfArray") |
547 |
FileObject[] files = findTestSources(context, true); |
555 |
FileObject[] files = findTestSources(context, true); |
|
|
556 |
if(files == null) { |
557 |
//user invoked "Test Package" action on a package with one test class |
558 |
files = findTestSources(context); |
559 |
} |
548 |
try { |
560 |
try { |
549 |
prepareSystemProperties(execProperties, command, context, true); |
561 |
prepareSystemProperties(execProperties, command2execute, context, true); |
550 |
execProperties.put(JavaRunner.PROP_EXECUTE_FILE, files[0]); |
562 |
execProperties.put(JavaRunner.PROP_EXECUTE_FILE, files[0]); |
551 |
if (buildDir != null) { // #211543 |
563 |
if (buildDir != null) { // #211543 |
552 |
execProperties.put("tmp.dir", updateHelper.getAntProjectHelper().resolvePath(buildDir)); |
564 |
execProperties.put("tmp.dir", updateHelper.getAntProjectHelper().resolvePath(buildDir)); |
553 |
} |
565 |
} |
554 |
updateJavaRunnerClasspath(command, execProperties); |
566 |
updateJavaRunnerClasspath(command2execute, execProperties); |
555 |
task = |
567 |
task = |
556 |
JavaRunner.execute(command.equals(COMMAND_TEST_SINGLE) ? JavaRunner.QUICK_TEST : (COMMAND_DEBUG_TEST_SINGLE.equals(command) ? JavaRunner.QUICK_TEST_DEBUG :JavaRunner.QUICK_TEST_PROFILE), |
568 |
JavaRunner.execute(command2execute.equals(COMMAND_TEST_SINGLE) ? JavaRunner.QUICK_TEST : (COMMAND_DEBUG_TEST_SINGLE.equals(command2execute) ? JavaRunner.QUICK_TEST_DEBUG :JavaRunner.QUICK_TEST_PROFILE), |
557 |
execProperties); |
569 |
execProperties); |
558 |
} catch (IOException ex) { |
570 |
} catch (IOException ex) { |
559 |
Exceptions.printStackTrace(ex); |
571 |
Exceptions.printStackTrace(ex); |
560 |
} |
572 |
} |
561 |
return; |
573 |
return; |
562 |
} |
574 |
} |
563 |
if (SingleMethod.COMMAND_RUN_SINGLE_METHOD.equals(command) || SingleMethod.COMMAND_DEBUG_SINGLE_METHOD.equals(command)) { |
575 |
if (SingleMethod.COMMAND_RUN_SINGLE_METHOD.equals(command2execute) || SingleMethod.COMMAND_DEBUG_SINGLE_METHOD.equals(command2execute)) { |
564 |
SingleMethod methodSpec = findTestMethods(context)[0]; |
576 |
SingleMethod methodSpec = findTestMethods(context)[0]; |
565 |
try { |
577 |
try { |
566 |
execProperties.put("methodname", methodSpec.getMethodName());//NOI18N |
578 |
execProperties.put("methodname", methodSpec.getMethodName());//NOI18N |
Lines 568-576
Link Here
|
568 |
if (buildDir != null) { |
580 |
if (buildDir != null) { |
569 |
execProperties.put("tmp.dir",updateHelper.getAntProjectHelper().resolvePath(buildDir)); |
581 |
execProperties.put("tmp.dir",updateHelper.getAntProjectHelper().resolvePath(buildDir)); |
570 |
} |
582 |
} |
571 |
updateJavaRunnerClasspath(command, execProperties); |
583 |
updateJavaRunnerClasspath(command2execute, execProperties); |
572 |
task = |
584 |
task = |
573 |
JavaRunner.execute(command.equals(SingleMethod.COMMAND_RUN_SINGLE_METHOD) ? JavaRunner.QUICK_TEST : JavaRunner.QUICK_TEST_DEBUG, |
585 |
JavaRunner.execute(command2execute.equals(SingleMethod.COMMAND_RUN_SINGLE_METHOD) ? JavaRunner.QUICK_TEST : JavaRunner.QUICK_TEST_DEBUG, |
574 |
execProperties); |
586 |
execProperties); |
575 |
} catch (IOException ex) { |
587 |
} catch (IOException ex) { |
576 |
Exceptions.printStackTrace(ex); |
588 |
Exceptions.printStackTrace(ex); |
Lines 578-589
Link Here
|
578 |
return; |
590 |
return; |
579 |
} |
591 |
} |
580 |
} |
592 |
} |
581 |
collectStartupExtenderArgs(p, command); |
593 |
collectStartupExtenderArgs(p, command2execute); |
582 |
Set<String> concealedProperties = collectAdditionalProperties(p, command, context); |
594 |
Set<String> concealedProperties = collectAdditionalProperties(p, command2execute, context); |
583 |
if (targetNames.length == 0) { |
595 |
if (targetNames.length == 0) { |
584 |
targetNames = null; |
596 |
targetNames = null; |
585 |
} |
597 |
} |
586 |
if (isCompileOnSaveEnabled && !NO_SYNC_COMMANDS.contains(command)) { |
598 |
if (isCompileOnSaveEnabled && !NO_SYNC_COMMANDS.contains(command2execute)) { |
587 |
p.put("nb.wait.for.caches", "true"); |
599 |
p.put("nb.wait.for.caches", "true"); |
588 |
} |
600 |
} |
589 |
final Callback cb = getCallback(); |
601 |
final Callback cb = getCallback(); |
Lines 599-605
Link Here
|
599 |
DialogDisplayer.getDefault().notify(nd); |
611 |
DialogDisplayer.getDefault().notify(nd); |
600 |
} else { |
612 |
} else { |
601 |
if (cb2 != null) { |
613 |
if (cb2 != null) { |
602 |
cb2.antTargetInvocationStarted(command, context); |
614 |
cb2.antTargetInvocationStarted(command2execute, context); |
603 |
} |
615 |
} |
604 |
try { |
616 |
try { |
605 |
task = ActionUtils.runTarget(buildFo, targetNames, p, concealedProperties); |
617 |
task = ActionUtils.runTarget(buildFo, targetNames, p, concealedProperties); |
Lines 615-633
Link Here
|
615 |
} |
627 |
} |
616 |
} finally { |
628 |
} finally { |
617 |
if (cb2 != null) { |
629 |
if (cb2 != null) { |
618 |
cb2.antTargetInvocationFinished(command, context, task.result()); |
630 |
cb2.antTargetInvocationFinished(command2execute, context, task.result()); |
619 |
} |
631 |
} |
620 |
} |
632 |
} |
621 |
} |
633 |
} |
622 |
}); |
634 |
}); |
623 |
} catch (IOException ex) { |
635 |
} catch (IOException ex) { |
624 |
if (cb2 != null) { |
636 |
if (cb2 != null) { |
625 |
cb2.antTargetInvocationFailed(command, context); |
637 |
cb2.antTargetInvocationFailed(command2execute, context); |
626 |
} |
638 |
} |
627 |
throw ex; |
639 |
throw ex; |
628 |
} catch (RuntimeException ex) { |
640 |
} catch (RuntimeException ex) { |
629 |
if (cb2 != null) { |
641 |
if (cb2 != null) { |
630 |
cb2.antTargetInvocationFailed(command, context); |
642 |
cb2.antTargetInvocationFailed(command2execute, context); |
631 |
} |
643 |
} |
632 |
throw ex; |
644 |
throw ex; |
633 |
} |
645 |
} |
Lines 792-802
Link Here
|
792 |
targetNames = getCommands().get(command); |
804 |
targetNames = getCommands().get(command); |
793 |
} else if ( command.equals( COMMAND_TEST_SINGLE ) ) { |
805 |
} else if ( command.equals( COMMAND_TEST_SINGLE ) ) { |
794 |
p.setProperty("ignore.failing.tests", "true"); //NOI18N |
806 |
p.setProperty("ignore.failing.tests", "true"); //NOI18N |
795 |
final FileObject[] files = findTestSources(context, true); |
807 |
final FileObject[] files = findTestSources(context); |
796 |
if (files == null) { |
808 |
if (files == null) { |
797 |
return null; |
809 |
return null; |
798 |
} |
810 |
} |
|
|
811 |
if(files.length == 1) { |
812 |
//one file or a package containing one file selected |
799 |
targetNames = setupTestSingle(p, files); |
813 |
targetNames = setupTestSingle(p, files); |
|
|
814 |
} else { |
815 |
//multiple files or package(s) selected |
816 |
targetNames = setupTestFilesOrPackages(p, files); |
817 |
} |
800 |
} else if ( command.equals( COMMAND_DEBUG_TEST_SINGLE ) ) { |
818 |
} else if ( command.equals( COMMAND_DEBUG_TEST_SINGLE ) ) { |
801 |
final FileObject[] files = findTestSources(context, true); |
819 |
final FileObject[] files = findTestSources(context, true); |
802 |
if (files == null) { |
820 |
if (files == null) { |
Lines 1366-1371
Link Here
|
1366 |
return new String[] {"test-single"}; // NOI18N |
1384 |
return new String[] {"test-single"}; // NOI18N |
1367 |
} |
1385 |
} |
1368 |
|
1386 |
|
|
|
1387 |
private String[] setupTestFilesOrPackages(Properties p, FileObject[] files) { |
1388 |
if (files != null) { |
1389 |
FileObject root = getRoot(projectTestRoots.getRoots(), files[0]); |
1390 |
p.setProperty("includes", ActionUtils.antIncludesList(files, root)); // NOI18N |
1391 |
} |
1392 |
return new String[]{"test"}; // NOI18N |
1393 |
} |
1394 |
|
1369 |
private String[] setupDebugTestSingle(Properties p, FileObject[] files) { |
1395 |
private String[] setupDebugTestSingle(Properties p, FileObject[] files) { |
1370 |
FileObject[] testSrcPath = projectTestRoots.getRoots(); |
1396 |
FileObject[] testSrcPath = projectTestRoots.getRoots(); |
1371 |
FileObject root = getRoot(testSrcPath, files[0]); |
1397 |
FileObject root = getRoot(testSrcPath, files[0]); |
Lines 1443-1450
Link Here
|
1443 |
|| findSourcesAndPackages( context, projectTestRoots.getRoots()) != null; |
1469 |
|| findSourcesAndPackages( context, projectTestRoots.getRoots()) != null; |
1444 |
} |
1470 |
} |
1445 |
else if ( command.equals( COMMAND_TEST_SINGLE ) ) { |
1471 |
else if ( command.equals( COMMAND_TEST_SINGLE ) ) { |
1446 |
FileObject[] fos = findTestSources(context, true); |
1472 |
FileObject[] fos = findTestSources(context); |
1447 |
return fos != null && fos.length == 1; |
1473 |
return fos != null; |
1448 |
} |
1474 |
} |
1449 |
else if ( command.equals( COMMAND_DEBUG_TEST_SINGLE ) ) { |
1475 |
else if ( command.equals( COMMAND_DEBUG_TEST_SINGLE ) ) { |
1450 |
FileObject[] fos = findTestSources(context, true); |
1476 |
FileObject[] fos = findTestSources(context, true); |
Lines 1545-1553
Link Here
|
1545 |
*/ |
1571 |
*/ |
1546 |
@org.netbeans.api.annotations.common.SuppressWarnings("PZLA_PREFER_ZERO_LENGTH_ARRAYS") |
1572 |
@org.netbeans.api.annotations.common.SuppressWarnings("PZLA_PREFER_ZERO_LENGTH_ARRAYS") |
1547 |
private @CheckForNull FileObject[] findSources(Lookup context) { |
1573 |
private @CheckForNull FileObject[] findSources(Lookup context) { |
|
|
1574 |
return findSources(context, true, false); |
1575 |
} |
1576 |
|
1577 |
/** |
1578 |
* Find selected source files |
1579 |
* |
1580 |
* @param context the lookup in which files should be found |
1581 |
* @param strict if true, all files in the selection have to be accepted |
1582 |
* @param findInPackages if true, all files under a selected package in the selection will also be checked |
1583 |
*/ |
1584 |
@org.netbeans.api.annotations.common.SuppressWarnings("PZLA_PREFER_ZERO_LENGTH_ARRAYS") |
1585 |
private @CheckForNull FileObject[] findSources(Lookup context, boolean strict, boolean findInPackages) { |
1548 |
FileObject[] srcPath = projectSourceRoots.getRoots(); |
1586 |
FileObject[] srcPath = projectSourceRoots.getRoots(); |
1549 |
for (int i=0; i< srcPath.length; i++) { |
1587 |
for (int i=0; i< srcPath.length; i++) { |
1550 |
FileObject[] files = ActionUtils.findSelectedFiles(context, srcPath[i], ".java", true); // NOI18N |
1588 |
FileObject[] files = ActionUtils.findSelectedFiles(context, srcPath[i], ".java", strict, findInPackages); // NOI18N |
1551 |
if (files != null) { |
1589 |
if (files != null) { |
1552 |
return files; |
1590 |
return files; |
1553 |
} |
1591 |
} |
Lines 1588-1612
Link Here
|
1588 |
*/ |
1626 |
*/ |
1589 |
@org.netbeans.api.annotations.common.SuppressWarnings("PZLA_PREFER_ZERO_LENGTH_ARRAYS") |
1627 |
@org.netbeans.api.annotations.common.SuppressWarnings("PZLA_PREFER_ZERO_LENGTH_ARRAYS") |
1590 |
private @CheckForNull FileObject[] findTestSources(Lookup context, boolean checkInSrcDir) { |
1628 |
private @CheckForNull FileObject[] findTestSources(Lookup context, boolean checkInSrcDir) { |
|
|
1629 |
return findTestSources(context, checkInSrcDir, true, false); |
1630 |
} |
1631 |
|
1632 |
/** |
1633 |
* Find selected tests and/or tests which belong to selected source files |
1634 |
* |
1635 |
* @param context the lookup in which files should be found |
1636 |
* @param checkInSrcDir if true, tests which belong to selected source files will be searched for |
1637 |
* @param strict if true, all files in the selection have to be accepted |
1638 |
* @param findInPackages if true, all files under a selected package in the selection will also be checked |
1639 |
*/ |
1640 |
@org.netbeans.api.annotations.common.SuppressWarnings("PZLA_PREFER_ZERO_LENGTH_ARRAYS") |
1641 |
private @CheckForNull FileObject[] findTestSources(Lookup context, boolean checkInSrcDir, boolean strict, boolean findInPackages) { |
1591 |
//XXX: Ugly, should be rewritten |
1642 |
//XXX: Ugly, should be rewritten |
1592 |
FileObject[] testSrcPath = projectTestRoots.getRoots(); |
1643 |
FileObject[] testSrcPaths = projectTestRoots.getRoots(); |
1593 |
for (int i=0; i< testSrcPath.length; i++) { |
1644 |
for (FileObject testSrcPath : testSrcPaths) { |
1594 |
FileObject[] files = ActionUtils.findSelectedFiles(context, testSrcPath[i], ".java", true); // NOI18N |
1645 |
FileObject[] files = ActionUtils.findSelectedFiles(context, testSrcPath, ".java", strict, findInPackages); // NOI18N |
1595 |
if (files != null) { |
1646 |
if (files != null) { |
1596 |
return files; |
1647 |
return files; |
1597 |
} |
1648 |
} |
1598 |
} |
1649 |
} |
1599 |
if (checkInSrcDir && testSrcPath.length>0) { |
1650 |
if (checkInSrcDir && testSrcPaths.length>0) { |
1600 |
FileObject[] files = findSources (context); |
1651 |
FileObject[] files = findSources (context, strict, findInPackages); |
1601 |
if (files != null) { |
1652 |
if (files != null) { |
1602 |
//Try to find the test under the test roots |
1653 |
//Try to find the test under the test roots |
1603 |
FileObject srcRoot = getRoot(projectSourceRoots.getRoots(),files[0]); |
1654 |
FileObject srcRoot = getRoot(projectSourceRoots.getRoots(),files[0]); |
1604 |
for (int i=0; i<testSrcPath.length; i++) { |
1655 |
for (FileObject testSrcPath : testSrcPaths) { |
1605 |
FileObject[] files2 = ActionUtils.regexpMapFiles(files,srcRoot, SRCDIRJAVA, testSrcPath[i], SUBST, true); |
1656 |
FileObject[] files2 = ActionUtils.regexpMapFiles(files, srcRoot, SRCDIRJAVA, testSrcPath, SUBST, strict); |
1606 |
if (files2 != null) { |
1657 |
if (files2 != null) { |
1607 |
return files2; |
1658 |
return files2; |
1608 |
} |
1659 |
} |
1609 |
FileObject[] files2NG = ActionUtils.regexpMapFiles(files, srcRoot, SRCDIRJAVA, testSrcPath[i], SUBSTNG, true); |
1660 |
FileObject[] files2NG = ActionUtils.regexpMapFiles(files, srcRoot, SRCDIRJAVA, testSrcPath, SUBSTNG, strict); |
1610 |
if (files2NG != null) { |
1661 |
if (files2NG != null) { |
1611 |
return files2NG; |
1662 |
return files2NG; |
1612 |
} |
1663 |
} |
Lines 1616-1621
Link Here
|
1616 |
return null; |
1667 |
return null; |
1617 |
} |
1668 |
} |
1618 |
|
1669 |
|
|
|
1670 |
/** |
1671 |
* Find selected tests and tests which belong to selected source files |
1672 |
* when package(s) or multiple files are selected. |
1673 |
* |
1674 |
* @param context the lookup in which files should be found |
1675 |
*/ |
1676 |
@org.netbeans.api.annotations.common.SuppressWarnings("PZLA_PREFER_ZERO_LENGTH_ARRAYS") |
1677 |
private @CheckForNull FileObject[] findTestSources(Lookup context) { |
1678 |
FileObject[] sourcesFOs = findSources(context, true, true); |
1679 |
FileObject[] testSourcesFOs = findTestSources(context, false, true, true); |
1680 |
HashSet<FileObject> testFiles = new HashSet<>(); |
1681 |
if(testSourcesFOs == null) { |
1682 |
return findTestSources(context, true, true, true); |
1683 |
} else { |
1684 |
if(sourcesFOs == null) { |
1685 |
return testSourcesFOs; |
1686 |
} else { |
1687 |
testFiles.addAll(Arrays.asList(testSourcesFOs)); |
1688 |
//Try to find the test under the test roots |
1689 |
FileObject srcRoot = getRoot(projectSourceRoots.getRoots(),sourcesFOs[0]); |
1690 |
for (FileObject testRoot : projectTestRoots.getRoots()) { |
1691 |
FileObject[] files2 = ActionUtils.regexpMapFiles(sourcesFOs, srcRoot, SRCDIRJAVA, testRoot, SUBST, true); |
1692 |
if (files2 != null) { |
1693 |
for (FileObject fo : files2) { |
1694 |
if(!testFiles.contains(fo)) { |
1695 |
testFiles.add(fo); |
1696 |
} |
1697 |
} |
1698 |
} |
1699 |
FileObject[] files2NG = ActionUtils.regexpMapFiles(sourcesFOs, srcRoot, SRCDIRJAVA, testRoot, SUBSTNG, true); |
1700 |
if (files2NG != null) { |
1701 |
for (FileObject fo : files2NG) { |
1702 |
if(!testFiles.contains(fo)) { |
1703 |
testFiles.add(fo); |
1704 |
} |
1705 |
} |
1706 |
} |
1707 |
} |
1708 |
} |
1709 |
} |
1710 |
return testFiles.isEmpty() ? null : testFiles.toArray(new FileObject[testFiles.size()]); |
1711 |
} |
1619 |
|
1712 |
|
1620 |
/** |
1713 |
/** |
1621 |
* Finds single method specification objects corresponding to JUnit test |
1714 |
* Finds single method specification objects corresponding to JUnit test |