author | smarks |
Wed, 25 May 2016 13:38:35 -0700 | |
changeset 38567 | 6d4c5a278fff |
parent 36778 | e04318f39f92 |
permissions | -rw-r--r-- |
28276
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
1 |
/* |
35356
e919fd8db52c
8056989: Sjavac --server option should be optional
alundblad
parents:
34473
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
28276
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
4 |
* |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
8 |
* |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
13 |
* accompanied this code). |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
14 |
* |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
18 |
* |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
21 |
* questions. |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
22 |
*/ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
23 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
24 |
import java.util.*; |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
25 |
import java.io.*; |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
26 |
import java.nio.file.*; |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
27 |
import java.nio.file.attribute.*; |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
28 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
29 |
import com.sun.tools.sjavac.Main; |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
30 |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
35356
diff
changeset
|
31 |
import toolbox.ToolBox; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
35356
diff
changeset
|
32 |
|
28276
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
33 |
public class SJavacTester { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
34 |
|
34473
5f7202c2125d
8144009: ToolBox should have a cleanDirectory method
alundblad
parents:
32799
diff
changeset
|
35 |
final ToolBox tb = new ToolBox(); |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
36 |
final Path TEST_ROOT = Paths.get(getClass().getSimpleName()); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
37 |
|
28276
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
38 |
// Generated sources that will test aspects of sjavac |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
39 |
final Path GENSRC = TEST_ROOT.resolve("gensrc"); |
28276
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
40 |
// Gensrc dirs used to test merging of serveral source roots. |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
41 |
final Path GENSRC2 = TEST_ROOT.resolve("gensrc2"); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
42 |
final Path GENSRC3 = TEST_ROOT.resolve("gensrc3"); |
28276
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
43 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
44 |
// Dir for compiled classes. |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
45 |
final Path BIN = TEST_ROOT.resolve("bin"); |
28276
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
46 |
// Dir for c-header files. |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
47 |
final Path HEADERS = TEST_ROOT.resolve("headers"); |
28276
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
48 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
49 |
// Remember the previous bin and headers state here. |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
50 |
Map<String,Long> previous_bin_state; |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
51 |
Map<String,Long> previous_headers_state; |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
52 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
53 |
void initialCompile() throws Exception { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
54 |
System.out.println("\nInitial compile of gensrc."); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
55 |
tb.writeFile(GENSRC.resolve("alfa/omega/AINT.java"), |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
56 |
"package alfa.omega; public interface AINT { void aint(); }"); |
28276
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
57 |
tb.writeFile(GENSRC.resolve("alfa/omega/A.java"), |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
58 |
"package alfa.omega; public class A implements AINT { "+ |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
59 |
"public final static int DEFINITION = 17; public void aint() { } }"); |
28276
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
60 |
tb.writeFile(GENSRC.resolve("alfa/omega/AA.java"), |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
61 |
"package alfa.omega;"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
62 |
"// A package private class, not contributing to the public api.\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
63 |
"class AA {"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
64 |
" // A properly nested static inner class.\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
65 |
" static class AAA { }\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
66 |
" // A properly nested inner class.\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
67 |
" class AAAA { }\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
68 |
" Runnable foo() {\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
69 |
" // A proper anonymous class.\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
70 |
" return new Runnable() { public void run() { } };\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
71 |
" }\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
72 |
" AAA aaa;\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
73 |
" AAAA aaaa;\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
74 |
" AAAAA aaaaa;\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
75 |
"}\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
76 |
"class AAAAA {\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
77 |
" // A bad auxiliary class, but no one is referencing it\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
78 |
" // from outside of this source file, therefore it is ok.\n"+ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
79 |
"}\n"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
80 |
tb.writeFile(GENSRC.resolve("beta/BINT.java"), |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
81 |
"package beta;public interface BINT { void foo(); }"); |
28276
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
82 |
tb.writeFile(GENSRC.resolve("beta/B.java"), |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
83 |
"package beta; import alfa.omega.A; public class B {"+ |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
84 |
"private int b() { return A.DEFINITION; } native void foo(); }"); |
28276
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
85 |
|
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
86 |
compile(GENSRC.toString(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
87 |
"-d", BIN.toString(), |
32799 | 88 |
"--state-dir=" + BIN, |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
89 |
"-h", HEADERS.toString(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
90 |
"-j", "1", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
28276
diff
changeset
|
91 |
"--log=debug"); |
28276
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
92 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
93 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
94 |
void removeFrom(Path dir, String... args) throws IOException { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
95 |
for (String filename : args) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
96 |
Path p = dir.resolve(filename); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
97 |
Files.delete(p); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
98 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
99 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
100 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
101 |
void compile(String... args) throws Exception { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
102 |
int rc = Main.go(args); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
103 |
if (rc != 0) throw new Exception("Error during compile!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
104 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
105 |
// Wait a second, to get around the (temporary) problem with |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
106 |
// second resolution in the Java file api. But do not do this |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
107 |
// on windows where the timestamps work. |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
108 |
long in_a_sec = System.currentTimeMillis()+1000; |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
109 |
while (in_a_sec > System.currentTimeMillis()) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
110 |
try { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
111 |
Thread.sleep(1000); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
112 |
} catch (InterruptedException e) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
113 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
114 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
115 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
116 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
117 |
void compileExpectFailure(String... args) throws Exception { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
118 |
int rc = Main.go(args); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
119 |
if (rc == 0) throw new Exception("Expected error during compile! Did not fail!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
120 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
121 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
122 |
Map<String,Long> collectState(Path dir) throws IOException { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
123 |
final Map<String,Long> files = new HashMap<>(); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
124 |
Files.walkFileTree(dir, new SimpleFileVisitor<Path>() { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
125 |
@Override |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
126 |
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
127 |
throws IOException |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
128 |
{ |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
129 |
files.put(file.toString(),new Long(Files.getLastModifiedTime(file).toMillis())); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
130 |
return FileVisitResult.CONTINUE; |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
131 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
132 |
}); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
133 |
return files; |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
134 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
135 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
136 |
void verifyThatFilesHaveBeenRemoved(Map<String,Long> from, |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
137 |
Map<String,Long> to, |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
138 |
String... args) throws Exception { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
139 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
140 |
Set<String> froms = from.keySet(); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
141 |
Set<String> tos = to.keySet(); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
142 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
143 |
if (froms.equals(tos)) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
144 |
throw new Exception("Expected new state to have fewer files than previous state!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
145 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
146 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
147 |
for (String t : tos) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
148 |
if (!froms.contains(t)) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
149 |
throw new Exception("Expected "+t+" to exist in previous state!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
150 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
151 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
152 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
153 |
for (String f : args) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
154 |
f = f.replace("/", File.separator); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
155 |
if (!froms.contains(f)) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
156 |
throw new Exception("Expected "+f+" to exist in previous state!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
157 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
158 |
if (tos.contains(f)) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
159 |
throw new Exception("Expected "+f+" to have been removed from the new state!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
160 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
161 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
162 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
163 |
if (froms.size() - args.length != tos.size()) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
164 |
throw new Exception("There are more removed files than the expected list!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
165 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
166 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
167 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
168 |
void verifyThatFilesHaveBeenAdded(Map<String,Long> from, |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
169 |
Map<String,Long> to, |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
170 |
String... args) throws Exception { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
171 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
172 |
Set<String> froms = from.keySet(); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
173 |
Set<String> tos = to.keySet(); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
174 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
175 |
if (froms.equals(tos)) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
176 |
throw new Exception("Expected new state to have more files than previous state!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
177 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
178 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
179 |
for (String t : froms) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
180 |
if (!tos.contains(t)) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
181 |
throw new Exception("Expected "+t+" to exist in new state!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
182 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
183 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
184 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
185 |
for (String f : args) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
186 |
f = f.replace("/", File.separator); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
187 |
if (!tos.contains(f)) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
188 |
throw new Exception("Expected "+f+" to have been added to new state!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
189 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
190 |
if (froms.contains(f)) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
191 |
throw new Exception("Expected "+f+" to not exist in previous state!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
192 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
193 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
194 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
195 |
if (froms.size() + args.length != tos.size()) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
196 |
throw new Exception("There are more added files than the expected list!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
197 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
198 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
199 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
200 |
void verifyNewerFiles(Map<String,Long> from, |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
201 |
Map<String,Long> to, |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
202 |
String... args) throws Exception { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
203 |
if (!from.keySet().equals(to.keySet())) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
204 |
throw new Exception("Expected the set of files to be identical!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
205 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
206 |
Set<String> files = new HashSet<String>(); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
207 |
for (String s : args) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
208 |
files.add(s.replace("/", File.separator)); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
209 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
210 |
for (String fn : from.keySet()) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
211 |
long f = from.get(fn); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
212 |
long t = to.get(fn); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
213 |
if (files.contains(fn)) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
214 |
if (t <= f) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
215 |
throw new Exception("Expected "+fn+" to have a more recent timestamp!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
216 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
217 |
} else { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
218 |
if (t != f) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
219 |
throw new Exception("Expected "+fn+" to have the same timestamp!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
220 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
221 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
222 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
223 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
224 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
225 |
String print(Map<String,Long> m) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
226 |
StringBuilder b = new StringBuilder(); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
227 |
Set<String> keys = m.keySet(); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
228 |
for (String k : keys) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
229 |
b.append(k+" "+m.get(k)+"\n"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
230 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
231 |
return b.toString(); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
232 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
233 |
|
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
234 |
void verifyEqual(Map<String,Long> from, Map<String,Long> to) throws Exception { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
235 |
if (!from.equals(to)) { |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
236 |
System.out.println("FROM---"+print(from)); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
237 |
System.out.println("TO-----"+print(to)); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
238 |
throw new Exception("The dir should not differ! But it does!"); |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
239 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
240 |
} |
ec66954fa850
8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff
changeset
|
241 |
} |