Closed yiming-tang-cs closed 6 years ago
We need some test cases:
testEntryPointFile
.
@EntryPoint
to m()
. This should pass because you now have an entry point.@EntryPoint
but add entry_points.txt
to https://github.com/ponder-lab/Java-8-Stream-Refactoring/tree/master/edu.cuny.hunter.streamrefactoring.tests/resources/ConvertStreamToParallel/testEntryPointFile. The entry_points.txt
file has the signature of the method, e.g., p.A.m();V
(please check if it fails). This would should pass just like the first test.q.A.m();V
in entry_points.txt
instead of p.A.m();V
. This one should fail with no entry point error. There's no annotation and no match in the file.entry_points.txt
to https://github.com/ponder-lab/Java-8-Stream-Refactoring/tree/master/edu.cuny.hunter.streamrefactoring.tests/resources/ConvertStreamToParallel. It should pass just the same as test 2.@EntryPoint
and there is also an entry_points.txt
file. Which would do we use? We should use the entry_points.txt file in this case. Please set up a case where the source has an @EntryPoint
but the entry_point.txt file has a different entry point. In this case, we should get a no entry point error for the stream.
- The above copy except that you add @EntryPoint to m(). This should pass because you now have an entry point. Done.
Remove @EntryPoint but add entry_points.txt to https://github.com/ponder-lab/Java-8-Stream-Refactoring/tree/master/edu.cuny.hunter.streamrefactoring.tests/resources/ConvertStreamToParallel/testEntryPointFile. The entry_points.txt file has the signature of the method, e.g., p.A.m();V (please check if it fails). This would should pass just like the first test.
It fails. The project directory is C:/Users/tangy/junit-workspace/TestProject1517962660629
.
WARNING: Project: TestProject1517962660629 has no entry points.
It seems that the JUnit uses the different workspace instead of the default workspace. The project directory which is detected by the tool is under junit-workspace
. Should we add a method to copy entry_points.txt
into junit-workspace
?
Let's start with the project directory and add the workspace file later.
Ok I see what you mean. It's not copying the txt file. We'll need to add some code to do that. Can you look into the testing infrastructure code and see where the source code is copied and see if you can also include the txt file? Otherwise, for now, you can debug the test by playing a breakpoint in the appropriate place and manually copy the txt file.
Ok I see what you mean. It's not copying the txt file. We'll need to add some code to do that. Can you look into the testing infrastructure code and see where the source code is copied and see if you can also include the txt file? Otherwise, for now, you can debug the test by playing a breakpoint in the appropriate place and manually copy the txt file.
I will look into the code tonight.
This is the way to copy source code:
It is not just copying. The source code is from the method getPackageP()
which is from org.eclipse.jdt.ui.tests
and I cannot see its code.
Remove @EntryPoint but add entry_points.txt to https://github.com/ponder-lab/Java-8-Stream-Refactoring/tree/master/edu.cuny.hunter.streamrefactoring.tests/resources/ConvertStreamToParallel/testEntryPointFile. The entry_points.txt file has the signature of the method, e.g., p.A.m();V (please check if it fails). This would should pass just like the first test.
DONE.
Same as test 2 but use q.A.m();V in entry_points.txt instead of p.A.m();V. This one should fail with no entry point error. There's no annotation and no match in the file.
DONE.
WARNING: Project: TestProject1518133667868 has no entry points.
After I changed the test code into
public void testEntryPointFile() throws Exception {
helper(new StreamAnalysisExpectedResult("h1.stream()", null, null, false, false, false, null, null, null,
RefactoringStatus.ERROR, EnumSet.of(PreconditionFailure.NO_ENTRY_POINT)));
}
, it could pass.
Same as test 2 but move entry_points.txt to https://github.com/ponder-lab/Java-8-Stream-Refactoring/tree/master/edu.cuny.hunter.streamrefactoring.tests/resources/ConvertStreamToParallel. It should pass just the same as test 2.
DONE.
After I investigate, the problem is from that the tool will scan the entry_points.txt
regardless of this TXT file belongs to the project which the tool is evaluating.
I found that the each test cases shared a same project space while multiple projects were evaluating. In #415 (d395867), they all shared the space of TestProject1518139267942
. When the tool tested testEntryPointFile
, it copied a file entry_points.txt
into TestProject1518139267942
, but the junit did not delete the txt file after the test testEntryPointFile
is finished. Then, when the following test cases start, the tool still scan the existed entry_points.txt
and import explicit entry points from the file. For the most test cases, it is fine, because the most test cases only contain a package named p
and a method names m
. However, for the test case testCollectionFromParameter
(code is shown below),
package p;
import java.util.HashSet;
import java.util.stream.*;
import edu.cuny.hunter.streamrefactoring.annotations.*;
class A {
@EntryPoint
void n() {
m(new HashSet<Object>());
}
void m(HashSet<Object> h) {
Stream<Object> stream = h.parallelStream();
stream.distinct().count();
}
}
, the old entry_points.txt
is not enough. The tool thinks that old entry_points.txt
belongs to this test case too and the tool imports explicit entry points from the old txt file, but those imported explicit entry points are not enough to evaluate this test case, that is why I got the error.
In addition, I've tested testCollectionFromParameter
independently in my local computer. It past, which means my understanding is correct.
My suggestion, create a new fold for entry_points.txt
and the name of fold is project name. Then, the tool can know which project the entry_points.txt
belongs to.
Related to #172.