Hi Dominique, 

Thank you for investigating. You're fix works. Should I repost this as a bug 
with your fix, or will this be picked up as is right now? 

Kind regard, 

Lodewijk 


Van: "Dominique Devienne" <ddevie...@gmail.com> 
Aan: "sqlite-users" <sqlite-users@mailinglists.sqlite.org> 
Verzonden: Dinsdag 17 oktober 2017 13:38:13 
Onderwerp: Re: [sqlite] Using .testcase and .check in continuous integration 
test 

On Tue, Oct 17, 2017 at 12:30 PM, Lodewijk Duymaer van Twist < 
lodew...@adesys.nl> wrote: 

> That would be an other way, but what I'm looking for is using the Command 
> Line Shell ".testcase" and ".check" method. 
> 

OK. That's new information :) 


> Create an example test file: 
> echo ".testcase 100 
> SELECT (1,2,3)<(1,2,4), (1,2,3)<(1,NULL,4), (1,2,3)<(2,NULL,1); 
> .check 1||1 
> 
> .testcase 110 
> SELECT (1,2,3)<(1,2,4), (1,2,3)<(1,NULL,4), (1,2,3)<(2,NULL,1); 
> .check 1|5|1" > test-script.sql 
> 
> Execute the test: 
> sqlite3 < test-script.sql 
> 
> Bail will not work for that. 
> 

shell.c needs to change for that, by 1 character I believe, in 
do_meta_command. 
In case of a failure, set rc to 1 instead of 2. That way the shell no 
longer exits 
with 0, but 1, i.e. an error. 

I'm actually surprised the result of do_meta_command() is not subject to 
.bail, 
and always exits if non-zero. 

Either do those changes yourself in your locally compiled shell, 
or hope Richard agrees the behavior should change. --DD 

rc = do_meta_command(azCmd[i], &data); 
if( rc ) return rc==2 ? 0 : rc; 

static int do_meta_command(char *zLine, ShellState *p){ 
... 
/* 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. 
*/ 
if( c=='c' && n>=3 && strncmp(azArg[0], "check", n)==0 ){ 
char *zRes = 0; 
output_reset(p); 
if( nArg!=2 ){ 
raw_printf(stderr, "Usage: .check GLOB-PATTERN\n"); 
rc = 2; 
}else if( (zRes = readFile("testcase-out.txt", 0))==0 ){ 
raw_printf(stderr, "Error: cannot read 'testcase-out.txt'\n"); 
rc = 2; 
}else if( testcase_glob(azArg[1],zRes)==0 ){ 
utf8_printf(stderr, 
"testcase-%s FAILED\n Expected: [%s]\n Got: [%s]\n", 
p->zTestcase, azArg[1], zRes); 
rc = 2; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< change to 1 
}else{ 
utf8_printf(stdout, "testcase-%s ok\n", p->zTestcase); 
p->nCheck++; 
} 
sqlite3_free(zRes); 
}else 
... 

meta_command_exit: 
if( p->outCount ){ 
p->outCount--; 
if( p->outCount==0 ) output_reset(p); 
} 
return rc; 
} 
_______________________________________________ 
sqlite-users mailing list 
sqlite-users@mailinglists.sqlite.org 
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users 
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to