1 package io.jawk.gawk;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import static org.junit.Assume.assumeTrue;
26
27 import java.io.IOException;
28 import java.nio.charset.StandardCharsets;
29 import java.nio.file.Files;
30 import java.nio.file.Path;
31 import io.jawk.CompatibilityTestResources;
32
33
34
35
36
37 abstract class AbstractGawkSuite {
38
39 protected static final Path GAWK_DIRECTORY = CompatibilityTestResources
40 .resourceDirectory(AbstractGawkSuite.class, "gawk");
41 protected static final String NON_ZERO_TRANSCRIPT_REASON = "This case compares a non-zero gawk CLI transcript, which is intentionally skipped in the explicit AwkTestSupport.cliTest suite.";
42 protected static final String NON_UTF8_STDIN_REASON = "This case redirects stdin that is not valid UTF-8, which is intentionally skipped in the explicit AwkTestSupport.cliTest suite.";
43 protected static final String NON_UTF8_EXPECTED_REASON = "This case uses an expected .ok file that is not valid UTF-8, which is intentionally skipped in the explicit AwkTestSupport.cliTest suite.";
44 protected static final String MANUAL_SKIP_REASON = "Handwritten gawk case from Makefile.am not yet expressed as an AwkTestSupport.cliTest case.";
45
46 protected static Path gawkPath(String fileName) {
47 return GAWK_DIRECTORY.resolve(fileName);
48 }
49
50 protected static String gawkFile(String fileName) {
51 return gawkPath(fileName).toString();
52 }
53
54 protected static String gawkText(String fileName) throws IOException {
55 return new String(Files.readAllBytes(gawkPath(fileName)), StandardCharsets.UTF_8);
56 }
57
58 protected static void skip(String reason) {
59 assumeTrue(reason, false);
60 }
61 }