From: stephan Date: Wed, 9 Aug 2023 15:46:55 +0000 (+0000) Subject: Extend TestScript to be able to report why it should be skipped. Expand the test... X-Git-Tag: version-3.43.0~47^2~45 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=65c7226e31d9d120474e2c7bc71accb16a21a881;p=thirdparty%2Fsqlite.git Extend TestScript to be able to report why it should be skipped. Expand the test-skipping rules to account for the current spec doc. Add the {} empty-string case to the spec doc. FossilOrigin-Name: 4fcc8cb0cc2bbc0da71bdb99dacfdec54814af4c0e4c37619bad6a8e5fa62937 --- diff --git a/ext/jni/src/org/sqlite/jni/tester/SQLTester.java b/ext/jni/src/org/sqlite/jni/tester/SQLTester.java index 1d26c6aecd..de18db491b 100644 --- a/ext/jni/src/org/sqlite/jni/tester/SQLTester.java +++ b/ext/jni/src/org/sqlite/jni/tester/SQLTester.java @@ -133,8 +133,8 @@ public class SQLTester { currentScript = ts; outln("----->>>>> ",ts.getModuleName()," [",ts.getName(),"]"); if( ts.isIgnored() ){ - outln("WARNING: skipping [",ts.getModuleName(),"] because it contains ", - "content which requires that it be skipped."); + outln("WARNING: skipping [",ts.getModuleName(),"]: ", + ts.getIgnoredReason()); continue; }else{ try{ @@ -272,6 +272,7 @@ public class SQLTester { spec doc. */ String escapeSqlValue(String v){ + if( "".equals(v) ) return "{}"; Matcher m = patternPlain.matcher(v); if( !m.find() ){ return v /* no escaping needed */; @@ -509,7 +510,8 @@ abstract class Command { //! Throws if content is not null. protected void affirmNoContent(String content) throws Exception{ if(null != content){ - Util.badArg(this.getClass().getName()," does not accept content."); + Util.badArg(this.getClass().getName()," does not accept content ", + "but got:\n",content); } } @@ -661,8 +663,9 @@ class ResultCommand extends Command { int rc = t.execSql(null, true, bufferMode, ResultRowMode.ONELINE, sql); final String result = t.getResultText().trim(); final String sArgs = argv.length>1 ? Util.argvToString(argv) : ""; - //t.verbose(argv[0]," result buffer:\n", result,"\nargs:\n",sArgs); if( !result.equals(sArgs) ){ + t.outln(argv[0]," FAILED comparison. Result buffer:\n", + result,"\nargs:\n",sArgs); Util.toss(TestFailure.class, argv[0]," comparison failed."); } } diff --git a/ext/jni/src/org/sqlite/jni/tester/TestScript.java b/ext/jni/src/org/sqlite/jni/tester/TestScript.java index 414ea29bc1..ce0fd9e237 100644 --- a/ext/jni/src/org/sqlite/jni/tester/TestScript.java +++ b/ext/jni/src/org/sqlite/jni/tester/TestScript.java @@ -27,7 +27,7 @@ class TestScript { private String moduleName = null; private List chunks = null; private final Outer outer = new Outer(); - private boolean ignored = false; + private String ignoreReason = null; /* One "chunk" of input, representing a single command and its optional body content. */ @@ -75,7 +75,11 @@ class TestScript { } public boolean isIgnored(){ - return ignored; + return null!=ignoreReason; + } + + public String getIgnoredReason(){ + return ignoreReason; } public void setVerbose(boolean b){ @@ -88,13 +92,30 @@ class TestScript { return this; } + private static final Pattern patternHashLine = + Pattern.compile("^#", Pattern.MULTILINE); /** Returns true if the given script content should be ignored (because it contains certain content which indicates such). */ - public boolean shouldBeIgnored(String content){ - return (null == moduleName) - || content.indexOf("\n|")>=0; + private boolean shouldBeIgnored(String content){ + if( null == moduleName ){ + ignoreReason = "No module name."; + return true; + }else if( content.indexOf("\n|")>=0 ){ + ignoreReason = "Contains newline-pipe combination."; + return true; + }else if( content.indexOf(" MODULE_NAME:")>=0 || + content.indexOf("MIXED_MODULE_NAME:")>=0 ){ + ignoreReason = "Incompatible module script."; + return true; + } + Matcher m = patternHashLine.matcher(content); + if( m.find() ){ + ignoreReason = "C-preprocessor line found."; + return true; + } + return false; } private boolean findModuleName(String content){ @@ -125,8 +146,7 @@ class TestScript { */ private List chunkContent(String content){ findModuleName(content); - ignored = shouldBeIgnored(content); - if( ignored ){ + if( shouldBeIgnored(content) ){ chunks = null; return null; } @@ -134,12 +154,10 @@ class TestScript { // 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"; final List lPats = new ArrayList<>(); lPats.add(sCComment); lPats.add(s3Dash); - lPats.add(sTclComment); lPats.add(sEmptyLine); //verbose("Content:").verbose(content).verbose(""); for( String s : lPats ){ diff --git a/ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md b/ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md index 5e89464664..cb0047d5b8 100644 --- a/ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md +++ b/ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md @@ -118,13 +118,16 @@ appended to the result buffer according to the following rules: (In this way, all column values and all row values are separated from each other by a single space.) - * If the sqlite3_column_text() returns NULL, then append "nil" - or + * If sqlite3_column_text() returns NULL, then append "nil" - or some other text that is specified by the --null command - and skip all subsequent rules. - * If sqlite3_column_text() does not contain any special characters, - append it to the result buffer without any formatting and skip all - subsequent rules. + * If sqlite3_column_text() is an empty string, append `{}` to the + result buffer and skip all subsequent rules. + + * If sqlite3_column_text() does not contain any special characters + (non-word characters), append it to the result buffer without + any formatting and skip all subsequent rules. * If sqlite3_column_text() does not contains curly braces, then put the text inside of `{...}` and append it and skip all subsequent rules. diff --git a/ext/jni/src/tests/000_first.test b/ext/jni/src/tests/000_first.test index db3d8e81f5..4998a9e3d7 100644 --- a/ext/jni/src/tests/000_first.test +++ b/ext/jni/src/tests/000_first.test @@ -4,11 +4,8 @@ ** */ -# this line is ignored - junk -# --open nope.db /* must throw */ --new SQLTester.db --run SELECT 1; diff --git a/manifest b/manifest index 1abf04a663..efe964956e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\sfor\sthe\s--null\scommand. -D 2023-08-09T14:47:01.213 +C Extend\sTestScript\sto\sbe\sable\sto\sreport\swhy\sit\sshould\sbe\sskipped.\sExpand\sthe\stest-skipping\srules\sto\saccount\sfor\sthe\scurrent\sspec\sdoc.\sAdd\sthe\s{}\sempty-string\scase\sto\sthe\sspec\sdoc. +D 2023-08-09T15:46:55.578 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -266,10 +266,10 @@ F ext/jni/src/org/sqlite/jni/sqlite3_context.java d26573fc7b309228cb49786e907859 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 3d9c40f8ed58ec0df05ca160986ea06ec84ec1f338b069cfba9604bbba467a01 -F ext/jni/src/org/sqlite/jni/tester/SQLTester.java 07592cf1ba9371a766a289df2f836458522f713e2934f08d06ba3da9dd6ea8c5 -F ext/jni/src/org/sqlite/jni/tester/TestScript.java f2a87c88ab23fa4601a985eb69bdc8b4f81cabfab04fdc3544ecefde207e08d4 -F ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md 480825a33a4d8df19aac8d6012b1041e0f679198a0ce9fbf189363e8167b51b1 -F ext/jni/src/tests/000_first.test 93905a390107748775acec1bb67dbc26c74e70e96b15f3723767f814d1453dfe +F ext/jni/src/org/sqlite/jni/tester/SQLTester.java 0889e3155178081ac1da419ab691d7c062ef0f36b7ee1b4560e02e7c0cbab897 +F ext/jni/src/org/sqlite/jni/tester/TestScript.java 3e284ba0ca456dd28e79f9283affbff870c0c58489c720e3cf9816299ab849cc +F ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md 7b461e9d0de3466273f6214bb5e97b9261b26277be83d26beea54f48ac9edcf0 +F ext/jni/src/tests/000_first.test 01cb22b7cad4bef6406ba61c230c6a120c2d800364fadefc503a4e313a6fbe97 F ext/jni/src/tests/010_ignored.test e17e874c6ab3c437f1293d88093cf06286083b65bf162317f91bbfd92f961b70 F ext/lsm1/Makefile a553b728bba6c11201b795188c5708915cc4290f02b7df6ba7e8c4c943fd5cd9 F ext/lsm1/Makefile.msc f8c878b467232226de288da320e1ac71c131f5ec91e08b21f502303347260013 @@ -2090,8 +2090,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 756ef83f45b69d9f78965ef1171d36477a32f938fe179e59b95f32f07849c0e5 -R 868fabec57c4571d02ece8c076384b8b +P 83ac815debcc75dac1fbbdc17736f5e33fb675fdab0bf649367592a0d18074e4 +R c4ccbbfa4d39592a7573f9290d04e09f U stephan -Z 7dc2fe1c269b136ee892b91b8b4ea8b6 +Z 30c0b98d0025fb4a06bfd82063ce05fe # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 48f5d78db6..67e6e5b317 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -83ac815debcc75dac1fbbdc17736f5e33fb675fdab0bf649367592a0d18074e4 \ No newline at end of file +4fcc8cb0cc2bbc0da71bdb99dacfdec54814af4c0e4c37619bad6a8e5fa62937 \ No newline at end of file