public void runTests() throws Exception {
// process each input file
for(String f : listInFiles){
- verbose("Running test script",f);
final TestScript ts = new TestScript(f);
ts.setVerbose(this.outer.getVerbose());
+ verbose("Test",ts.getName(),"...");
ts.dump();
}
}
*/
public class TestScript {
//! Test script content.
+ private String name;
private String content;
+ private List<String> chunks = null;
private final Outer outer = new Outer();
+ private boolean ignored = false;
- private byte[] readFile(String filename) throws IOException {
+ private byte[] readFile(String filename) throws Exception {
return java.nio.file.Files.readAllBytes(java.nio.file.Paths.get(filename));
}
private void setContent(String c){
content = c;
+ ignored = shouldBeIgnored(c);
+ chunks = chunkContent();
}
/**
Initializes the script with the content of the given file.
*/
- public TestScript(String filename) throws IOException{
+ public TestScript(String filename) throws Exception{
setContent(new String(readFile(filename),
java.nio.charset.StandardCharsets.UTF_8));
+ name = filename;
}
/**
- Initializes the script with the given content, copied
- at construction-time.
+ Initializes the script with the given content, copied at
+ construction-time. The first argument is a filename for that
+ content. It need not refer to a real file - it's for display
+ purposes only.
*/
- public TestScript(StringBuffer content){
+ public TestScript(String virtualName, StringBuffer content)
+ throws RuntimeException {
setContent(content.toString());
+ name = virtualName;
+ }
+
+ public String getName(){
+ return name;
+ }
+
+ public boolean isIgnored(){
+ return ignored;
}
public void setVerbose(boolean b){
return this;
}
+ /**
+ Returns true if the given script content should be ignored
+ (because it contains certain content which indicates such).
+ */
+ public static boolean shouldBeIgnored(String content){
+ return content.indexOf("SCRIPT_MODULE_NAME")>=0
+ || content.indexOf("\n|")>=0;
+ }
+
/**
A quick-and-dirty approach to chopping a script up into individual
- commands. The primary problem with this is that it will remove any
- C-style comments from expected script output, which might or might not
- be a real problem.
- */
- private List<String> chunkContent(String input){
- final String sCComment =
- "[/][*]([*](?![/])|[^*])*[*][/]"
- //"/\\*[^/*]*(?:(?!/\\*|\\*/)[/*][^/*]*)*\\*/"
- ;
+ commands and their inputs.
+ */
+ private List<String> chunkContent(){
+ if( ignored ) return null;
+ // First, strip out any content which we know we can ignore...
+ final String sCComment = "[/][*]([*](?![/])|[^*])*[*][/]";
final String s3Dash = "^---+[^\\n]*\\n";
final String sTclComment = "^#[^\\n]*\\n";
final String sEmptyLine = "^\\n";
lPats.add(s3Dash);
lPats.add(sTclComment);
lPats.add(sEmptyLine);
- //verbose("Content:").verbose(input).verbose("<EOF>");
- String tmp = input;
+ //verbose("Content:").verbose(content).verbose("<EOF>");
+ String tmp = content;
for( String s : lPats ){
final Pattern p = Pattern.compile(
s, Pattern.MULTILINE
//while( m.find() ) verbose("#"+(++n)+"\t",m.group(0).trim());
tmp = m.replaceAll("");
}
- // Chunk the newly-stripped text into individual commands.
+ // Chunk the newly-cleaned text into individual commands and their input...
final String sCommand = "^--";
final List<String> rc = new ArrayList<>();
final Pattern p = Pattern.compile(
in some form or other (possibly mangled from its original).
*/
public void dump(){
- List<String> list = chunkContent(content);
- verbose("script chunked by command:");
- int n = 0;
- for(String c : list){
- verbose("#"+(++n),c);
+ if( null==chunks ){
+ verbose("This contains content which forces it to be ignored.");
+ }else{
+ verbose("script commands:");
+ int n = 0;
+ for(String c : chunks){
+ verbose("#"+(++n),c);
+ }
+ verbose("<EOF>");
}
- verbose("<EOF>");
}
}
## Parsing Rules:
1. Ignore the entire script if the script does not contain the
- string "SCRIPT_MODULE_NAME:".
+ string "SCRIPT_MODULE_NAME:".
2. Ignore any script that contains the character sequence "\\n\|"
(0x0a, 0x7c). In other words, ignore scripts that contain the
## Commands:
-Each command looks like an SQL comment. The command begins at the left
+Each command looks like an SQL comment. The command begins at the left
margin (no leading space) and starts with exactly 2 minus signs ("-").
The command name consists of lowercase letters and maybe a "-" or two.
Some commands have arguments.
The arguments are separated from the command name by one or more spaces.
Commands have access to the input buffer and might reset the input buffer.
-The command can also optionally read (and consume) additional text from
+The command can also optionally read (and consume) additional text from
script that comes after the command.
Unknown or unrecognized commands should cause an error message to be
--- /dev/null
+/* This script must be marked as ignored because it contains
+ content which triggers that condition. */
+
+|
-C SQLTester\scan\snow\ssplit\sa\stest\sscript\sinto\sa\sseries\sof\sindividual\scommands.
-D 2023-08-07T22:32:22.258
+C SQLTester\snow\signores\stests\swhich\scontain\sconstructs\sspecified\sin\sthe\sspec\sdoc.
+D 2023-08-07T23:04:17.593
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F ext/jni/src/org/sqlite/jni/sqlite3_stmt.java 78e6d1b95ac600a9475e9db4623f69449322b0c93d1bd4e1616e76ed547ed9fc
F ext/jni/src/org/sqlite/jni/sqlite3_value.java 3d1d4903e267bc0bc81d57d21f5e85978eff389a1a6ed46726dbe75f85e6914a
F ext/jni/src/org/sqlite/jni/tester/Outer.java 8931ff9f152d22a822ff98831a4e924da48016ff1f1f84042390a6f51ad7b48f
-F ext/jni/src/org/sqlite/jni/tester/SQLTester.java edcab1ea3d7848523416b881061f8095e8f7ae2a626e07947a55a4215898e040
-F ext/jni/src/org/sqlite/jni/tester/TestScript.java 00007d167ce5b40506a624bad1fb8571a0b975285849a7bd8fd7c0ebcfb3f785
-F ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md ba3cf6584783939c8797a67203e63ec588430fdc0b7719f24873e6731c6d0445
+F ext/jni/src/org/sqlite/jni/tester/SQLTester.java 1ee4ef9c65c9eedf6bfd68ad807346592ee01faf7fad16c3f18c462ed4c98c38
+F ext/jni/src/org/sqlite/jni/tester/TestScript.java 374bdad5cd0597aa9e20e5b8abd077a41d92caae6190ce383c250cb08859e7e4
+F ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md 2627f8ac7c3d3f502404d9a9b8481bad5c2d11df7fdf25fbd0e1dbd2bcaa54c3
F ext/jni/src/tests/000_first.test a06b72b6815246a21f6a4b14126bbc40b9cd1e3b03410431ed50203cfa942e9b
+F ext/jni/src/tests/010_ignored.test ce2de6742ff1bf98d8976fda0f260ff3d280e8f8c0a99309fb59fcfef2556fcd
F ext/lsm1/Makefile a553b728bba6c11201b795188c5708915cc4290f02b7df6ba7e8c4c943fd5cd9
F ext/lsm1/Makefile.msc f8c878b467232226de288da320e1ac71c131f5ec91e08b21f502303347260013
F ext/lsm1/lsm-test/README 87ea529d2abe615e856d4714bfe8bb185e6c2771b8612aa6298588b7b43e6f86
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 59bd392817ac69ffdf60ab7a2094b0d616bf593da060b6acf1b4ce9837847fcb
-R 63407ef8cfa2823943afd16b1a637995
+P d3d1accc8b4ba0cd396ee3a58d9710a54b8e1d1b171d67595d4ef1fc7faea8cb
+R d5c9761c7876583110d4d0a8a0b413b4
U stephan
-Z 2b2535b40ad95e4630d07d7436d967c8
+Z e82e467651a46849ab5637959c044f1b
# Remove this line to create a well-formed Fossil manifest.
-d3d1accc8b4ba0cd396ee3a58d9710a54b8e1d1b171d67595d4ef1fc7faea8cb
\ No newline at end of file
+ecaeee652aa2cc6893ded9231d7e9b2783465516016740b307b74e4e81598ae3
\ No newline at end of file