mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-27 20:41:58 +03:00
SQLTester now ignores tests which contain constructs specified in the spec doc.
FossilOrigin-Name: ecaeee652aa2cc6893ded9231d7e9b2783465516016740b307b74e4e81598ae3
This commit is contained in:
@ -36,9 +36,9 @@ public class SQLTester {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -14,30 +14,48 @@ import java.util.regex.*;
|
||||
*/
|
||||
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){
|
||||
@ -50,17 +68,23 @@ public class TestScript {
|
||||
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";
|
||||
@ -69,8 +93,8 @@ public class TestScript {
|
||||
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
|
||||
@ -83,7 +107,7 @@ public class TestScript {
|
||||
//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(
|
||||
@ -110,12 +134,15 @@ public class TestScript {
|
||||
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>");
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ script are deleted when the script finishes.
|
||||
## 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
|
||||
@ -37,14 +37,14 @@ script are deleted when the script finishes.
|
||||
|
||||
## 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
|
||||
|
4
ext/jni/src/tests/010_ignored.test
Normal file
4
ext/jni/src/tests/010_ignored.test
Normal file
@ -0,0 +1,4 @@
|
||||
/* This script must be marked as ignored because it contains
|
||||
content which triggers that condition. */
|
||||
|
||||
|
|
Reference in New Issue
Block a user