From: drh Date: Fri, 16 Sep 2016 02:52:22 +0000 (+0000) Subject: In the shell, make ".testcase" and ".check" available in all configurations, X-Git-Tag: version-3.15.0~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=760c8162fffd53f660adf4b3cdaf7aee7070d845;p=thirdparty%2Fsqlite.git In the shell, make ".testcase" and ".check" available in all configurations, not just SQLITE_DEBUG. All testcases to be named. Show the result of each testcase on stdout. FossilOrigin-Name: 792afefa9c750910082fd102f1ccd10309759dfc --- diff --git a/manifest b/manifest index d7517fc830..2ce97c3919 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\scommand-line\sshell,\sadd\sthe\s--new\soption\sto\sthe\s".open"\scommand.\nAlso,\sreport\sthe\scurrent\sdatabase\sfilename\sas\spart\sof\sthe\s".show"\scommand. -D 2016-09-16T00:26:08.684 +C In\sthe\sshell,\smake\s".testcase"\sand\s".check"\savailable\sin\sall\sconfigurations,\nnot\sjust\sSQLITE_DEBUG.\s\sAll\stestcases\sto\sbe\snamed.\s\sShow\sthe\sresult\sof\seach\ntestcase\son\sstdout. +D 2016-09-16T02:52:22.198 F Makefile.in 6fd48ffcf7c2deea7499062d1f3747f986c19678 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e1aa788e84f926e42239ee167c53f785bedacacd @@ -387,7 +387,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 24f40fd0c3475821d1ad762a3f2c3455cc839b42 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 244f9cc5e4662987cd2ef5c22d1b7027560f3425 -F src/shell.c 1de20c816872f5443a104bdae238ff142e887f9e +F src/shell.c 2c558e83e0961de364570182c0ff26395d7aaba0 F src/sqlite.h.in 46ed821aeed0ba45559fb15597d9a400083154a2 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae @@ -1525,7 +1525,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 62289f27ee276090a855982bd8216a465e7d0a27 -R d4e2f1f820d6f2b9a8e052f36c44661c +P 8e5c92039128a430e0509f4f06ea80ba39c35bda +R 46d709a281b0ceda3453ac789078f257 U drh -Z d98a4b3e23d9525e29325cc221e2ffa0 +Z 03a0324123b8a87d967c8d29c327e230 diff --git a/manifest.uuid b/manifest.uuid index 1013449e87..354fefec67 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8e5c92039128a430e0509f4f06ea80ba39c35bda \ No newline at end of file +792afefa9c750910082fd102f1ccd10309759dfc \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 6c9bf7cd32..e1a4089bb0 100644 --- a/src/shell.c +++ b/src/shell.c @@ -626,8 +626,10 @@ struct ShellState { int normalMode; /* Output mode before ".explain on" */ int writableSchema; /* True if PRAGMA writable_schema=ON */ int showHeader; /* True to show column names in List or Column mode */ + int nCheck; /* Number of ".check" commands run */ unsigned shellFlgs; /* Various flags */ char *zDestTable; /* Name of destination table when MODE_Insert */ + char zTestcase[30]; /* Name of current test case */ char colSeparator[20]; /* Column separator character for several modes */ char rowSeparator[20]; /* Row separator character for MODE_Ascii */ int colWidth[100]; /* Requested width of each column when in column mode*/ @@ -2136,9 +2138,7 @@ static char zHelp[] = ".bail on|off Stop after hitting an error. Default OFF\n" ".binary on|off Turn binary output on or off. Default OFF\n" ".changes on|off Show number of rows changed by SQL\n" -#ifdef SQLITE_DEBUG ".check GLOB Fail if output since .testcase does not match\n" -#endif ".clone NEWDB Clone data into NEWDB from the existing database\n" ".databases List names and files of attached databases\n" ".dbinfo ?DB? Show status information about the database\n" @@ -2200,9 +2200,7 @@ static char zHelp[] = ".tables ?TABLE? List names of tables\n" " If TABLE specified, only list tables matching\n" " LIKE pattern TABLE.\n" -#ifdef SQLITE_DEBUG - ".testcase Begin redirecting output to 'testcase-out.txt'\n" -#endif + ".testcase NAME Begin redirecting output to 'testcase-out.txt'\n" ".timeout MS Try opening locked tables for MS milliseconds\n" ".timer on|off Turn SQL timer on or off\n" ".trace FILE|off Output each SQL statement as it is run\n" @@ -3360,7 +3358,6 @@ static int do_meta_command(char *zLine, ShellState *p){ } }else -#ifdef SQLITE_DEBUG /* Cancel output redirection, if it is currently set (by .testcase) ** Then read the content of the testcase-out.txt file and compare against ** azArg[1]. If there are differences, report an error and exit. @@ -3370,18 +3367,21 @@ static int do_meta_command(char *zLine, ShellState *p){ output_reset(p); if( nArg!=2 ){ raw_printf(stderr, "Usage: .check GLOB-PATTERN\n"); - rc = 1; + rc = 2; }else if( (zRes = readFile("testcase-out.txt"))==0 ){ raw_printf(stderr, "Error: cannot read 'testcase-out.txt'\n"); rc = 2; }else if( testcase_glob(azArg[1],zRes)==0 ){ - raw_printf(stderr, ".check failed\n Expected: [%s]\n Got: [%s]\n", - azArg[1], zRes); + raw_printf(stderr, + "testcase-%s FAILED\n Expected: [%s]\n Got: [%s]\n", + p->zTestcase, azArg[1], zRes); rc = 2; + }else{ + raw_printf(stdout, "testcase-%s ok\n", p->zTestcase); + p->nCheck++; } sqlite3_free(zRes); }else -#endif if( c=='c' && strncmp(azArg[0], "clone", n)==0 ){ if( nArg==2 ){ @@ -3993,20 +3993,27 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='o' && strncmp(azArg[0], "open", n)==0 && n>=2 ){ char *zNewFilename; /* Name of the database file to open */ int iName = 1; /* Index in azArg[] of the filename */ + int newFlag = 0; /* True to delete file before opening */ /* Close the existing database */ session_close_all(p); sqlite3_close(p->db); p->db = 0; sqlite3_free(p->zFreeOnClose); p->zFreeOnClose = 0; - /* Start a new database file if the --new flag is present */ - if( nArg>2 && optionMatch(azArg[1],"new") ){ - iName++; - if( nArg>iName ) shellDeleteFile(azArg[iName]); + /* Check for command-line arguments */ + for(iName=1; iNameiName ? sqlite3_mprintf("%s", azArg[iName]) : 0; if( zNewFilename ){ + if( newFlag ) shellDeleteFile(zNewFilename); p->zDbFilename = zNewFilename; open_db(p, 1); if( p->db==0 ){ @@ -4668,7 +4675,6 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_free(azResult); }else -#ifdef SQLITE_DEBUG /* Begin redirecting output to the file "testcase-out.txt" */ if( c=='t' && strcmp(azArg[0],"testcase")==0 ){ output_reset(p); @@ -4676,8 +4682,12 @@ static int do_meta_command(char *zLine, ShellState *p){ if( p->out==0 ){ utf8_printf(stderr, "Error: cannot open 'testcase-out.txt'\n"); } + if( nArg>=2 ){ + sqlite3_snprintf(sizeof(p->zTestcase), p->zTestcase, "%s", azArg[1]); + }else{ + sqlite3_snprintf(sizeof(p->zTestcase), p->zTestcase, "?"); + } }else -#endif if( c=='t' && n>=8 && strncmp(azArg[0], "testctrl", n)==0 && nArg>=2 ){ static const struct {