StateDir.java revision 2958:27da0c3ac83a
131744Shelbig/* 231744Shelbig * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 331744Shelbig * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 431744Shelbig * 531744Shelbig * This code is free software; you can redistribute it and/or modify it 631744Shelbig * under the terms of the GNU General Public License version 2 only, as 731744Shelbig * published by the Free Software Foundation. Oracle designates this 831744Shelbig * particular file as subject to the "Classpath" exception as provided 931744Shelbig * by Oracle in the LICENSE file that accompanied this code. 1031744Shelbig * 1131744Shelbig * This code is distributed in the hope that it will be useful, but WITHOUT 1231744Shelbig * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1331744Shelbig * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1431744Shelbig * version 2 for more details (a copy is included in the LICENSE file that 1531744Shelbig * accompanied this code). 1631744Shelbig * 1731744Shelbig * You should have received a copy of the GNU General Public License version 1831744Shelbig * 2 along with this work; if not, write to the Free Software Foundation, 1931744Shelbig * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2031744Shelbig * 2131744Shelbig * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2231744Shelbig * or visit www.oracle.com if you need additional information or have any 2331744Shelbig * questions. 2431744Shelbig */ 2531744Shelbig 2632310Scharnier/* 2732310Scharnier * @test 2832310Scharnier * @summary Verify that --state-dir=bar works 2950477Speter * @bug 8054689 3032310Scharnier * @author Fredrik O 3132310Scharnier * @author sogoel (rewrite) 3231744Shelbig * @library /tools/lib 3374612Sache * @modules jdk.compiler/com.sun.tools.javac.api 3431744Shelbig * jdk.compiler/com.sun.tools.javac.file 3574573Sache * jdk.compiler/com.sun.tools.javac.main 3631744Shelbig * jdk.compiler/com.sun.tools.sjavac 3731744Shelbig * @build Wrapper ToolBox 3831744Shelbig * @run main Wrapper StateDir 3931744Shelbig */ 4031744Shelbig 4131744Shelbigimport java.util.*; 4231744Shelbigimport java.nio.file.*; 43189804Sdas 44189804Sdaspublic class StateDir extends SJavacTester { 4531744Shelbig public static void main(String... args) throws Exception { 4631744Shelbig StateDir sd = new StateDir(); 4731744Shelbig sd.test(); 4831744Shelbig } 4931744Shelbig 5031744Shelbig void test() throws Exception { 5131744Shelbig clean(TEST_ROOT); 5231744Shelbig Path BAR = TEST_ROOT.resolve("bar"); 5331744Shelbig Files.createDirectories(BAR); 5431744Shelbig Files.createDirectories(BIN); 5531744Shelbig 5631744Shelbig Map<String,Long> previous_bin_state = collectState(BIN); 5731744Shelbig Map<String,Long> previous_bar_state = collectState(BAR); 58189804Sdas 5931744Shelbig ToolBox tb = new ToolBox(); 6031744Shelbig tb.writeFile(GENSRC.resolve("alfa/omega/A.java"), 6131744Shelbig "package alfa.omega; public class A { }"); 6231744Shelbig 6331744Shelbig compile("--state-dir=" + BAR, 64189804Sdas "-src", GENSRC.toString(), 6531744Shelbig "-d", BIN.toString(), 6631744Shelbig SJavacTester.SERVER_ARG); 6731744Shelbig 6831744Shelbig Map<String,Long> new_bin_state = collectState(BIN); 6995641Smarkm verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state, 7095641Smarkm BIN + "/alfa/omega/A.class"); 7131744Shelbig Map<String,Long> new_bar_state = collectState(BAR); 7231744Shelbig verifyThatFilesHaveBeenAdded(previous_bar_state, new_bar_state, 7353963Sache BAR + "/javac_state"); 7453963Sache clean(GENSRC, BIN, BAR); 7553963Sache } 7653963Sache} 7753963Sache