StateDir.java revision 3573:c4a18ee691c4
12Sjlaskey/* 26Sjlaskey * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. 32Sjlaskey * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4877Sattila * 52Sjlaskey * This code is free software; you can redistribute it and/or modify it 62Sjlaskey * under the terms of the GNU General Public License version 2 only, as 72Sjlaskey * published by the Free Software Foundation. 8877Sattila * 92Sjlaskey * This code is distributed in the hope that it will be useful, but WITHOUT 102Sjlaskey * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 112Sjlaskey * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 122Sjlaskey * version 2 for more details (a copy is included in the LICENSE file that 132Sjlaskey * accompanied this code). 14877Sattila * 152Sjlaskey * You should have received a copy of the GNU General Public License version 162Sjlaskey * 2 along with this work; if not, write to the Free Software Foundation, 172Sjlaskey * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18877Sattila * 192Sjlaskey * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 202Sjlaskey * or visit www.oracle.com if you need additional information or have any 212Sjlaskey * questions. 222Sjlaskey */ 232Sjlaskey 242Sjlaskey/* 252Sjlaskey * @test 262Sjlaskey * @summary Verify that --state-dir=bar works 272Sjlaskey * @bug 8054689 282Sjlaskey * @author Fredrik O 292Sjlaskey * @author sogoel (rewrite) 302Sjlaskey * @library /tools/lib 312Sjlaskey * @modules jdk.compiler/com.sun.tools.javac.api 322Sjlaskey * jdk.compiler/com.sun.tools.javac.main 332Sjlaskey * jdk.compiler/com.sun.tools.sjavac 342Sjlaskey * @build Wrapper toolbox.ToolBox 352Sjlaskey * @run main Wrapper StateDir 362Sjlaskey */ 372Sjlaskey 382Sjlaskeyimport java.util.*; 392Sjlaskeyimport java.nio.file.*; 402Sjlaskey 412Sjlaskeypublic class StateDir extends SJavacTester { 422Sjlaskey public static void main(String... args) throws Exception { 432Sjlaskey StateDir sd = new StateDir(); 442Sjlaskey sd.test(); 452Sjlaskey } 462Sjlaskey 472Sjlaskey void test() throws Exception { 482Sjlaskey Path BAR = TEST_ROOT.resolve("bar"); 49 Files.createDirectories(BAR); 50 Files.createDirectories(BIN); 51 52 Map<String,Long> previous_bin_state = collectState(BIN); 53 Map<String,Long> previous_bar_state = collectState(BAR); 54 55 tb.writeFile(GENSRC.resolve("alfa/omega/A.java"), 56 "package alfa.omega; public class A { }"); 57 58 compile("--state-dir=" + BAR, 59 "-src", GENSRC.toString(), 60 "-d", BIN.toString()); 61 62 Map<String,Long> new_bin_state = collectState(BIN); 63 verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state, 64 BIN + "/alfa/omega/A.class"); 65 Map<String,Long> new_bar_state = collectState(BAR); 66 verifyThatFilesHaveBeenAdded(previous_bar_state, new_bar_state, 67 BAR + "/javac_state"); 68 } 69} 70