ottlinger commented on code in PR #390: URL: https://github.com/apache/creadur-rat/pull/390#discussion_r1840085599
########## apache-rat-core/src/it/java/org/apache/rat/ReportTest.java: ########## @@ -0,0 +1,205 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.rat; + +import groovy.lang.Binding; +import groovy.lang.GroovyShell; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.PrintStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.DefaultParser; +import org.apache.commons.io.IOCase; +import org.apache.commons.io.IOUtils; +import org.apache.commons.io.filefilter.AbstractFileFilter; +import org.apache.commons.io.filefilter.DirectoryFileFilter; +import org.apache.commons.io.filefilter.NameFileFilter; +import org.apache.commons.io.filefilter.OrFileFilter; +import org.apache.commons.lang3.StringUtils; +import org.apache.rat.api.Document; +import org.apache.rat.api.RatException; +import org.apache.rat.commandline.Arg; +import org.apache.rat.document.DocumentName; +import org.apache.rat.document.DocumentNameMatcher; +import org.apache.rat.document.FileDocument; +import org.apache.rat.document.RatDocumentAnalysisException; +import org.apache.rat.report.RatReport; +import org.apache.rat.utils.DefaultLog; +import org.apache.rat.utils.Log; +import org.apache.rat.walker.DirectoryWalker; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; + +/** + * Integration tests for the {@link Report} class. + * Integration tests must have a specific structure. + * <ul> + * <li>They are in directories under {@code src/it/resources/ReportText/X} where {@code X} is the name of the test. Usually + * a reference to a reported bug.</li> + * <li>Within the directory is a file named {@code commandLine.txt}. Each line in the file is a single command line + * token. For example "--output-style XML" would be 2 lines in the file "--output-style" and "XML"</li> + * <li>Within the directory there is a subdirectory named {@code src}. This is the root of the file system for RAT to scan.</li> + * <li>There may be a {@code notes.md} describing the test</li> + * <li>There is a {@code verify.groovy} script. When executed: + * <ul> + * <li>The first parameter will be then name of the file that captured the output.</li> + * <li>The second parameter will be the name of the file that captured the log.</li> + * <li>Any assert that fails within the Groovy script will fail the test.</li> + * <li>Any value returned from the script execution will fail the test and the returned value will be + * used as the failure message.</li> + * </ul> + * </li> + * <li>If an exception is expected when Report is run with the command line a file named {@code expected-message.txt} + * must be present in the directory. It must contain text that is expected to be found within the message + * associated with the exception.</li> + * </ul> + */ +public class ReportTest { + + private String[] asArgs(final List<String> argsList) { + return argsList.toArray(new String[argsList.size()]); + } + + @ParameterizedTest(name = "{index} {0}") + @MethodSource("args") + public void integrationTest(String testName, Document commandLineDoc) throws Exception { Review Comment: Shouldn't all this parsing functionality be put into the tools-submodule? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@creadur.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org