// Path: src/main/java/net/nicoulaj/compilecommand/CompileCommandProcessor.java
// public static final String COMPILE_COMMAND_FILE_PATH_DEFAULT = "META-INF/hotspot_compiler";
// 
// Path: src/main/java/net/nicoulaj/compilecommand/CompileCommandProcessor.java
// public static final String COMPILE_COMMAND_INCREMENTAL_OUTPUT_OPTION = "compile.command.incremental.output";
// 
// Path: src/test/java/net/nicoulaj/compilecommand/JavaCompilationTester.java
// public static final class Report {
// 
//     private final File classesDirectory;
// 
//     private final File sourcesDirectory;
// 
//     private final boolean successful;
// 
//     private final List<Diagnostic<? extends JavaFileObject>> diagnostics;
// 
//     private final String stdout;
// 
//     Report(final File classesDirectory,
//            final File sourcesDirectory,
//            final boolean successful,
//            final List<Diagnostic<? extends JavaFileObject>> diagnostics,
//            final String stdout) {
//         this.classesDirectory = classesDirectory;
//         this.sourcesDirectory = sourcesDirectory;
//         this.successful = successful;
//         this.diagnostics = diagnostics;
//         this.stdout = stdout;
//     }
// 
//     public File getClassesDirectory() {
//         return classesDirectory;
//     }
// 
//     public File getSourcesDirectory() {
//         return sourcesDirectory;
//     }
// 
//     public boolean isSuccessful() {
//         return successful;
//     }
// 
//     public boolean isFailed() {
//         return !successful;
//     }
// 
//     public boolean hasErrors() {
//         return !successful;
//     }
// 
//     public boolean hasWarnings() {
//         for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics)
//             if (diagnostic.getKind() == WARNING || diagnostic.getKind() == MANDATORY_WARNING)
//                 return true;
//         return false;
//     }
// 
//     public List<Diagnostic<? extends JavaFileObject>> getDiagnostics() {
//         return diagnostics;
//     }
// 
//     public String getStdout() {
//         return stdout;
//     }
// }


import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static java.util.Arrays.sort;
import static net.nicoulaj.compilecommand.CompileCommandProcessor.COMPILE_COMMAND_FILE_PATH_DEFAULT;
import static net.nicoulaj.compilecommand.CompileCommandProcessor.COMPILE_COMMAND_INCREMENTAL_OUTPUT_OPTION;
import static net.nicoulaj.compilecommand.JavaCompilationTester.Report;
import static org.apache.commons.io.FilenameUtils.getBaseName;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
/*
 * Hotspot compile command annotations - http://compile-command-annotations.nicoulaj.net
 * Copyright © 2014-2019 Hotspot compile command annotations contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.nicoulaj.compilecommand;




public class IncrementalCompileTest {
    private static final JavaCompilationTester JAVAC = new JavaCompilationTester();

    private static final File TEST_CASES_SOURCES = new File("src/test/java/net/nicoulaj/compilecommand/incrementaltests");

    private static final File TEST_CASES_RESOURCES = new File("src/test/resources/net/nicoulaj/compilecommand/incrementaltests");

    private static final File TEST_CASES_MERGED = new File("src/test/resources/net/nicoulaj/compilecommand/incrementaltests-merged");

    private static final String INCREMENTAL_FRAGMENTS = "INCREMENTAL_FRAGMENTS";

    @DataProvider
    public Object[][] testcases() throws IOException {
        return getDataProvider(TEST_CASES_SOURCES, TEST_CASES_RESOURCES, TEST_CASES_MERGED);
    }

    private Object[][] getDataProvider(File sourceDir, File resourceDir, File mergedDir) {
        final List<Object[]> data = new ArrayList<Object[]>();
        final File[] sources = sourceDir.listFiles();
        if (sources == null) throw new IllegalArgumentException("No source in " + sourceDir);
        sort(sources);
        for (File source : sources)
            if ("java".equals(getExtension(source.toString())))
                if (!"package-info".equals(getBaseName(source.toString())))
                    data.add(new Object[]{source,
                                          new File(resourceDir, getBaseName(source.toString())),
                                          new File(mergedDir, getBaseName(source.toString()))});
        return data.toArray(new Object[data.size()][]);
    }

    @Test(dataProvider = "testcases")
    public void test(File source, File expected, File expectedMerged) throws IOException
    {
// Path: src/main/java/net/nicoulaj/compilecommand/CompileCommandProcessor.java
// public static final String COMPILE_COMMAND_FILE_PATH_DEFAULT = "META-INF/hotspot_compiler";
// 
// Path: src/main/java/net/nicoulaj/compilecommand/CompileCommandProcessor.java
// public static final String COMPILE_COMMAND_INCREMENTAL_OUTPUT_OPTION = "compile.command.incremental.output";
// 
// Path: src/test/java/net/nicoulaj/compilecommand/JavaCompilationTester.java
// public static final class Report {
// 
//     private final File classesDirectory;
// 
//     private final File sourcesDirectory;
// 
//     private final boolean successful;
// 
//     private final List<Diagnostic<? extends JavaFileObject>> diagnostics;
// 
//     private final String stdout;
// 
//     Report(final File classesDirectory,
//            final File sourcesDirectory,
//            final boolean successful,
//            final List<Diagnostic<? extends JavaFileObject>> diagnostics,
//            final String stdout) {
//         this.classesDirectory = classesDirectory;
//         this.sourcesDirectory = sourcesDirectory;
//         this.successful = successful;
//         this.diagnostics = diagnostics;
//         this.stdout = stdout;
//     }
// 
//     public File getClassesDirectory() {
//         return classesDirectory;
//     }
// 
//     public File getSourcesDirectory() {
//         return sourcesDirectory;
//     }
// 
//     public boolean isSuccessful() {
//         return successful;
//     }
// 
//     public boolean isFailed() {
//         return !successful;
//     }
// 
//     public boolean hasErrors() {
//         return !successful;
//     }
// 
//     public boolean hasWarnings() {
//         for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics)
//             if (diagnostic.getKind() == WARNING || diagnostic.getKind() == MANDATORY_WARNING)
//                 return true;
//         return false;
//     }
// 
//     public List<Diagnostic<? extends JavaFileObject>> getDiagnostics() {
//         return diagnostics;
//     }
// 
//     public String getStdout() {
//         return stdout;
//     }
// }


// Path: src/test/java/net/nicoulaj/compilecommand/IncrementalCompileTest.java
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static java.util.Arrays.sort;
import static net.nicoulaj.compilecommand.CompileCommandProcessor.COMPILE_COMMAND_FILE_PATH_DEFAULT;
import static net.nicoulaj.compilecommand.CompileCommandProcessor.COMPILE_COMMAND_INCREMENTAL_OUTPUT_OPTION;
import static net.nicoulaj.compilecommand.JavaCompilationTester.Report;
import static org.apache.commons.io.FilenameUtils.getBaseName;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

/*
 * Hotspot compile command annotations - http://compile-command-annotations.nicoulaj.net
 * Copyright © 2014-2019 Hotspot compile command annotations contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.nicoulaj.compilecommand;




public class IncrementalCompileTest {
    private static final JavaCompilationTester JAVAC = new JavaCompilationTester();

    private static final File TEST_CASES_SOURCES = new File("src/test/java/net/nicoulaj/compilecommand/incrementaltests");

    private static final File TEST_CASES_RESOURCES = new File("src/test/resources/net/nicoulaj/compilecommand/incrementaltests");

    private static final File TEST_CASES_MERGED = new File("src/test/resources/net/nicoulaj/compilecommand/incrementaltests-merged");

    private static final String INCREMENTAL_FRAGMENTS = "INCREMENTAL_FRAGMENTS";

    @DataProvider
    public Object[][] testcases() throws IOException {
        return getDataProvider(TEST_CASES_SOURCES, TEST_CASES_RESOURCES, TEST_CASES_MERGED);
    }

    private Object[][] getDataProvider(File sourceDir, File resourceDir, File mergedDir) {
        final List<Object[]> data = new ArrayList<Object[]>();
        final File[] sources = sourceDir.listFiles();
        if (sources == null) throw new IllegalArgumentException("No source in " + sourceDir);
        sort(sources);
        for (File source : sources)
            if ("java".equals(getExtension(source.toString())))
                if (!"package-info".equals(getBaseName(source.toString())))
                    data.add(new Object[]{source,
                                          new File(resourceDir, getBaseName(source.toString())),
                                          new File(mergedDir, getBaseName(source.toString()))});
        return data.toArray(new Object[data.size()][]);
    }

    @Test(dataProvider = "testcases")
    public void test(File source, File expected, File expectedMerged) throws IOException
    {
        final Report compilation = JAVAC.compile(source,