|
| 1 | +/* |
| 2 | + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | + * accompanied this code). |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License version |
| 16 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | + * |
| 19 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | + * or visit www.oracle.com if you need additional information or have any |
| 21 | + * questions. |
| 22 | + */ |
| 23 | + |
| 24 | +package org.openjdk.jextract.test.toolprovider.includeDeps; |
| 25 | + |
| 26 | +import org.testng.annotations.BeforeClass; |
| 27 | +import org.testng.annotations.DataProvider; |
| 28 | +import org.testng.annotations.Test; |
| 29 | +import testlib.JextractToolRunner; |
| 30 | + |
| 31 | +import java.nio.file.Path; |
| 32 | +import java.util.ArrayList; |
| 33 | +import java.util.List; |
| 34 | +import java.util.stream.Collectors; |
| 35 | +import java.util.stream.Stream; |
| 36 | + |
| 37 | +public class TestNestedBadIncludes extends JextractToolRunner { |
| 38 | + |
| 39 | + JextractResult result; |
| 40 | + |
| 41 | + @BeforeClass |
| 42 | + public void before() { |
| 43 | + Path output = getOutputFilePath("TestNestedBadIncludes-nestedBadIncludes.h"); |
| 44 | + Path outputH = getInputFilePath("nested_bad_includes.h"); |
| 45 | + List<String> options = new ArrayList<>(); |
| 46 | + Stream.of(cases()).flatMap( |
| 47 | + arr -> Stream.of((String)arr[0], (String)arr[1]) |
| 48 | + ).collect(Collectors.toCollection(() -> options)); |
| 49 | + options.add(outputH.toString()); |
| 50 | + result = run(output, options.toArray(new String[0])); |
| 51 | + result.checkFailure(FAILURE); |
| 52 | + } |
| 53 | + |
| 54 | + @Test(dataProvider = "cases") |
| 55 | + public void testBadIncludes(String includeOption, String badDeclName, String missingDepName) { |
| 56 | + result.checkContainsOutput("ERROR: " + badDeclName + " depends on " + missingDepName); |
| 57 | + } |
| 58 | + |
| 59 | + @DataProvider |
| 60 | + public static Object[][] cases() { |
| 61 | + return new Object[][]{ |
| 62 | + {"--include-typedef", "t_str", "A" }, |
| 63 | + {"--include-function", "f_str_arg", "A" }, |
| 64 | + {"--include-function", "f_str_ret", "A" }, |
| 65 | + {"--include-var", "v_str", "A" }, |
| 66 | + {"--include-typedef", "t_fp_arg", "A" }, |
| 67 | + {"--include-typedef", "t_fp_ret", "A" }, |
| 68 | + {"--include-function", "f_fp_arg", "A" }, |
| 69 | + {"--include-function", "f_fp_ret", "A" }, |
| 70 | + {"--include-var", "v_fp_arg", "A" }, |
| 71 | + {"--include-var", "v_fp_ret", "A" }, |
| 72 | + }; |
| 73 | + } |
| 74 | +} |
0 commit comments