Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Updated and added new test cases for CLI. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
29e3c8da1bd3971215036e5f5cfa5b25 |
User & Date: | shaneh 2009-12-17 21:07:54.000 |
Context
2009-12-17
| ||
22:12 | Fixed some TCL test cases to work if SQLITE_OMIT_TRIGGER is defined. (check-in: 85e3c73497 user: shaneh tags: trunk) | |
21:07 | Updated and added new test cases for CLI. (check-in: 29e3c8da1b user: shaneh tags: trunk) | |
21:07 | In shell.c (CLI), modified local_getline() to remove '\r' as well as '\n' from end of lines. This provides consistency between MSVC and CYGWIN builds. (check-in: b1b48be1cf user: shaneh tags: trunk) | |
Changes
Changes to tool/shell1.test.
︙ | ︙ | |||
19 20 21 22 23 24 25 | # shell1-1.*: Basic command line option handling. # shell1-2.*: Basic "dot" command token parsing. # shell1-3.*: Basic test that "dot" command can be called. # package require sqlite3 | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # shell1-1.*: Basic command line option handling. # shell1-2.*: Basic "dot" command token parsing. # shell1-3.*: Basic test that "dot" command can be called. # package require sqlite3 set CLI "./sqlite3" proc do_test {name cmd expected} { puts -nonewline "$name ..." set res [uplevel $cmd] if {$res eq $expected} { puts Ok } else { |
︙ | ︙ | |||
43 44 45 46 47 48 49 | } proc catchsql {sql} { set rc [catch {uplevel [list db eval $sql]} msg] list $rc $msg } | | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | } proc catchsql {sql} { set rc [catch {uplevel [list db eval $sql]} msg] list $rc $msg } proc catchcmd {db {cmd ""}} { global CLI set out [open cmds.txt w] puts $out $cmd close $out set line "exec $CLI $db < cmds.txt" set rc [catch { eval $line } msg] list $rc $msg |
︙ | ︙ | |||
75 76 77 78 79 80 81 | do_test shell1-1.1.2 { set res [catchcmd "-bad test.db \"select 3\" \"select 4\"" ""] set rc [lindex $res 0] list $rc \ [regexp {Error: too many options: "select 4"} $res] } {1 1} # error on extra options | | | | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | do_test shell1-1.1.2 { set res [catchcmd "-bad test.db \"select 3\" \"select 4\"" ""] set rc [lindex $res 0] list $rc \ [regexp {Error: too many options: "select 4"} $res] } {1 1} # error on extra options do_test shell1-1.1.3 { set res [catchcmd "-bad FOO test.db BAD" ".quit"] set rc [lindex $res 0] list $rc \ [regexp {Error: too many options: "BAD"} $res] } {1 1} # -help do_test shell1-1.2.1 { set res [catchcmd "-help test.db" ""] set rc [lindex $res 0] list $rc \ [regexp {Usage} $res] \ [regexp {\-init} $res] \ [regexp {\-version} $res] } {1 1 1 1} # -init filename read/process named file do_test shell1-1.3.1 { catchcmd "-init FOO test.db" "" } {0 {}} do_test shell1-1.3.2 { set res [catchcmd "-init FOO test.db .quit BAD" ""] set rc [lindex $res 0] list $rc \ [regexp {Error: too many options: "BAD"} $res] } {1 1} |
︙ | ︙ | |||
191 192 193 194 195 196 197 | list $rc \ [regexp {Error: missing argument for option: -nullvalue} $res] } {1 1} # -version show SQLite version do_test shell1-1.16.1 { catchcmd "-version test.db" "" | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 | list $rc \ [regexp {Error: missing argument for option: -nullvalue} $res] } {1 1} # -version show SQLite version do_test shell1-1.16.1 { catchcmd "-version test.db" "" } {0 3.6.21} #---------------------------------------------------------------------------- # Test cases shell1-2.*: Basic "dot" command token parsing. # # check first token handling do_test shell1-2.1.1 { catchcmd "test.db" ".foo" } {1 {Error: unknown command or invalid arguments: "foo". Enter ".help" for help}} do_test shell1-2.1.2 { catchcmd "test.db" ".\"foo OFF\"" } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}} do_test shell1-2.1.3 { catchcmd "test.db" ".\'foo OFF\'" } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}} # unbalanced quotes do_test shell1-2.2.1 { catchcmd "test.db" ".\"foo OFF" } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}} do_test shell1-2.2.2 { catchcmd "test.db" ".\'foo OFF" } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}} do_test shell1-2.2.3 { catchcmd "test.db" ".explain \"OFF" } {0 {}} do_test shell1-2.2.4 { catchcmd "test.db" ".explain \'OFF" } {0 {}} do_test shell1-2.2.5 { catchcmd "test.db" ".mode \"insert FOO" } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} do_test shell1-2.2.6 { catchcmd "test.db" ".mode \'insert FOO" } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} # check multiple tokens, and quoted tokens do_test shell1-2.3.1 { catchcmd "test.db" ".explain 1" } {0 {}} do_test shell1-2.3.2 { catchcmd "test.db" ".explain on" } {0 {}} do_test shell1-2.3.3 { catchcmd "test.db" ".explain \"1 2 3\"" } {0 {}} do_test shell1-2.3.4 { catchcmd "test.db" ".explain \"OFF\"" } {0 {}} do_test shell1-2.3.5 { catchcmd "test.db" ".\'explain\' \'OFF\'" } {0 {}} do_test shell1-2.3.6 { catchcmd "test.db" ".explain \'OFF\'" } {0 {}} do_test shell1-2.3.7 { catchcmd "test.db" ".\'explain\' \'OFF\'" } {0 {}} # check quoted args are unquoted do_test shell1-2.4.1 { catchcmd "test.db" ".mode FOO" } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} do_test shell1-2.4.2 { catchcmd "test.db" ".mode csv" } {0 {}} do_test shell1-2.4.2 { catchcmd "test.db" ".mode \"csv\"" } {0 {}} #---------------------------------------------------------------------------- # Test cases shell1-3.*: Basic test that "dot" command can be called. # # .backup ?DB? FILE Backup DB (default "main") to FILE do_test shell1-3.1.1 { catchcmd "test.db" ".backup" } {1 {Error: unknown command or invalid arguments: "backup". Enter ".help" for help}} do_test shell1-3.1.2 { catchcmd "test.db" ".backup FOO" } {0 {}} do_test shell1-3.1.3 { catchcmd "test.db" ".backup FOO BAR" } {1 {Error: unknown database FOO}} do_test shell1-3.1.4 { # too many arguments catchcmd "test.db" ".backup FOO BAR BAD" } {1 {Error: unknown command or invalid arguments: "backup". Enter ".help" for help}} # .bail ON|OFF Stop after hitting an error. Default OFF do_test shell1-3.2.1 { catchcmd "test.db" ".bail" } {1 {Error: unknown command or invalid arguments: "bail". Enter ".help" for help}} do_test shell1-3.2.2 { catchcmd "test.db" ".bail ON" } {0 {}} do_test shell1-3.2.3 { catchcmd "test.db" ".bail OFF" } {0 {}} do_test shell1-3.2.4 { # too many arguments catchcmd "test.db" ".bail OFF BAD" } {1 {Error: unknown command or invalid arguments: "bail". Enter ".help" for help}} # .databases List names and files of attached databases do_test shell1-3.3.1 { set res [catchcmd "test.db" ".databases"] regexp {0.*main.*test\.db} $res } {1} do_test shell1-3.3.2 { # too many arguments catchcmd "test.db" ".databases BAD" } {1 {Error: unknown command or invalid arguments: "databases". Enter ".help" for help}} # .dump ?TABLE? ... Dump the database in an SQL text format # If TABLE specified, only dump tables matching # LIKE pattern TABLE. do_test shell1-3.4.1 { set res [catchcmd "test.db" ".dump"] list [regexp {BEGIN TRANSACTION;} $res] \ [regexp {COMMIT;} $res] } {1 1} do_test shell1-3.4.2 { set res [catchcmd "test.db" ".dump FOO"] list [regexp {BEGIN TRANSACTION;} $res] \ [regexp {COMMIT;} $res] } {1 1} do_test shell1-3.4.3 { # too many arguments catchcmd "test.db" ".dump FOO BAD" } {1 {Error: unknown command or invalid arguments: "dump". Enter ".help" for help}} # .echo ON|OFF Turn command echo on or off do_test shell1-3.5.1 { catchcmd "test.db" ".echo" } {1 {Error: unknown command or invalid arguments: "echo". Enter ".help" for help}} do_test shell1-3.5.2 { catchcmd "test.db" ".echo ON" } {0 {}} do_test shell1-3.5.3 { catchcmd "test.db" ".echo OFF" } {0 {}} do_test shell1-3.5.4 { # too many arguments catchcmd "test.db" ".echo OFF BAD" } {1 {Error: unknown command or invalid arguments: "echo". Enter ".help" for help}} # .exit Exit this program do_test shell1-3.6.1 { catchcmd "test.db" ".exit" } {0 {}} do_test shell1-3.6.2 { # too many arguments catchcmd "test.db" ".exit BAD" } {1 {Error: unknown command or invalid arguments: "exit". Enter ".help" for help}} # .explain ON|OFF Turn output mode suitable for EXPLAIN on or off. do_test shell1-3.7.1 { catchcmd "test.db" ".explain" # explain is the exception to the booleans. without an option, it turns it on. } {0 {}} do_test shell1-3.7.2 { catchcmd "test.db" ".explain ON" } {0 {}} do_test shell1-3.7.3 { catchcmd "test.db" ".explain OFF" } {0 {}} do_test shell1-3.7.4 { # too many arguments catchcmd "test.db" ".explain OFF BAD" } {1 {Error: unknown command or invalid arguments: "explain". Enter ".help" for help}} # .genfkey ?OPTIONS? Options are: # --no-drop: Do not drop old fkey triggers. # --ignore-errors: Ignore tables with fkey errors # --exec: Execute generated SQL immediately # See file tool/genfkey.README in the source # distribution for further information. do_test shell1-3.8.1 { catchcmd "test.db" ".genfkey" } {0 {}} do_test shell1-3.8.2 { catchcmd "test.db" ".genfkey FOO" } {1 {unknown option: FOO}} # .header(s) ON|OFF Turn display of headers on or off do_test shell1-3.9.1 { catchcmd "test.db" ".header" } {1 {Error: unknown command or invalid arguments: "header". Enter ".help" for help}} do_test shell1-3.9.2 { catchcmd "test.db" ".header ON" } {0 {}} do_test shell1-3.9.3 { catchcmd "test.db" ".header OFF" } {0 {}} do_test shell1-3.9.4 { # too many arguments catchcmd "test.db" ".header OFF BAD" } {1 {Error: unknown command or invalid arguments: "header". Enter ".help" for help}} do_test shell1-3.9.5 { catchcmd "test.db" ".headers" } {1 {Error: unknown command or invalid arguments: "headers". Enter ".help" for help}} do_test shell1-3.9.6 { catchcmd "test.db" ".headers ON" } {0 {}} do_test shell1-3.9.7 { catchcmd "test.db" ".headers OFF" } {0 {}} do_test shell1-3.9.8 { # too many arguments catchcmd "test.db" ".headers OFF BAD" } {1 {Error: unknown command or invalid arguments: "headers". Enter ".help" for help}} # .help Show this message do_test shell1-3.10.1 { set res [catchcmd "test.db" ".help"] # look for a few of the possible help commands list [regexp {.help} $res] \ [regexp {.quit} $res] \ [regexp {.show} $res] } {1 1 1} do_test shell1-3.10.2 { # we allow .help to take extra args (it is help after all) set res [catchcmd "test.db" ".help BAD"] # look for a few of the possible help commands list [regexp {.help} $res] \ [regexp {.quit} $res] \ [regexp {.show} $res] } {1 1 1} # .import FILE TABLE Import data from FILE into TABLE do_test shell1-3.11.1 { catchcmd "test.db" ".import" } {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}} do_test shell1-3.11.2 { catchcmd "test.db" ".import FOO" } {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}} do_test shell1-3.11.2 { catchcmd "test.db" ".import FOO BAR" } {1 {Error: no such table: BAR}} do_test shell1-3.11.3 { # too many arguments catchcmd "test.db" ".import FOO BAR BAD" } {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}} # .indices ?TABLE? Show names of all indices # If TABLE specified, only show indices for tables # matching LIKE pattern TABLE. do_test shell1-3.12.1 { catchcmd "test.db" ".indices" } {0 {}} do_test shell1-3.12.2 { catchcmd "test.db" ".indices FOO" } {0 {}} do_test shell1-3.12.3 { # too many arguments catchcmd "test.db" ".indices FOO BAD" } {1 {Error: unknown command or invalid arguments: "indices". Enter ".help" for help}} # .mode MODE ?TABLE? Set output mode where MODE is one of: # csv Comma-separated values # column Left-aligned columns. (See .width) # html HTML <table> code # insert SQL insert statements for TABLE # line One value per line # list Values delimited by .separator string # tabs Tab-separated values # tcl TCL list elements do_test shell1-3.13.1 { catchcmd "test.db" ".mode" } {1 {Error: unknown command or invalid arguments: "mode". Enter ".help" for help}} do_test shell1-3.13.2 { catchcmd "test.db" ".mode FOO" } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} do_test shell1-3.13.3 { catchcmd "test.db" ".mode csv" } {0 {}} do_test shell1-3.13.4 { catchcmd "test.db" ".mode column" } {0 {}} do_test shell1-3.13.5 { catchcmd "test.db" ".mode html" } {0 {}} do_test shell1-3.13.6 { catchcmd "test.db" ".mode insert" } {0 {}} do_test shell1-3.13.7 { catchcmd "test.db" ".mode line" } {0 {}} do_test shell1-3.13.8 { catchcmd "test.db" ".mode list" } {0 {}} do_test shell1-3.13.9 { catchcmd "test.db" ".mode tabs" } {0 {}} do_test shell1-3.13.10 { catchcmd "test.db" ".mode tcl" } {0 {}} do_test shell1-3.13.11 { # too many arguments catchcmd "test.db" ".mode tcl BAD" } {1 {Error: invalid arguments: "BAD". Enter ".help" for help}} # don't allow partial mode type matches do_test shell1-3.13.12 { catchcmd "test.db" ".mode l" } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} do_test shell1-3.13.13 { catchcmd "test.db" ".mode li" } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} do_test shell1-3.13.14 { catchcmd "test.db" ".mode lin" } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} # .nullvalue STRING Print STRING in place of NULL values do_test shell1-3.14.1 { catchcmd "test.db" ".nullvalue" } {1 {Error: unknown command or invalid arguments: "nullvalue". Enter ".help" for help}} do_test shell1-3.14.2 { catchcmd "test.db" ".nullvalue FOO" } {0 {}} do_test shell1-3.14.3 { # too many arguments catchcmd "test.db" ".nullvalue FOO BAD" } {1 {Error: unknown command or invalid arguments: "nullvalue". Enter ".help" for help}} # .output FILENAME Send output to FILENAME do_test shell1-3.15.1 { catchcmd "test.db" ".output" } {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}} do_test shell1-3.15.2 { catchcmd "test.db" ".output FOO" } {0 {}} do_test shell1-3.15.3 { # too many arguments catchcmd "test.db" ".output FOO BAD" } {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}} # .output stdout Send output to the screen do_test shell1-3.16.1 { catchcmd "test.db" ".output stdout" } {0 {}} do_test shell1-3.16.2 { # too many arguments catchcmd "test.db" ".output stdout BAD" } {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}} # .prompt MAIN CONTINUE Replace the standard prompts do_test shell1-3.17.1 { catchcmd "test.db" ".prompt" } {1 {Error: unknown command or invalid arguments: "prompt". Enter ".help" for help}} do_test shell1-3.17.2 { catchcmd "test.db" ".prompt FOO" } {0 {}} do_test shell1-3.17.3 { catchcmd "test.db" ".prompt FOO BAR" } {0 {}} do_test shell1-3.17.4 { # too many arguments catchcmd "test.db" ".prompt FOO BAR BAD" } {1 {Error: unknown command or invalid arguments: "prompt". Enter ".help" for help}} # .quit Exit this program do_test shell1-3.18.1 { catchcmd "test.db" ".quit" } {0 {}} do_test shell1-3.18.2 { # too many arguments catchcmd "test.db" ".quit BAD" } {1 {Error: unknown command or invalid arguments: "quit". Enter ".help" for help}} # .read FILENAME Execute SQL in FILENAME do_test shell1-3.19.1 { catchcmd "test.db" ".read" } {1 {Error: unknown command or invalid arguments: "read". Enter ".help" for help}} do_test shell1-3.19.2 { file delete -force FOO catchcmd "test.db" ".read FOO" } {1 {Error: cannot open "FOO"}} do_test shell1-3.19.3 { # too many arguments catchcmd "test.db" ".read FOO BAD" } {1 {Error: unknown command or invalid arguments: "read". Enter ".help" for help}} # .restore ?DB? FILE Restore content of DB (default "main") from FILE do_test shell1-3.20.1 { catchcmd "test.db" ".restore" } {1 {Error: unknown command or invalid arguments: "restore". Enter ".help" for help}} do_test shell1-3.20.2 { catchcmd "test.db" ".restore FOO" } {0 {}} do_test shell1-3.20.3 { catchcmd "test.db" ".restore FOO BAR" } {1 {Error: unknown database FOO}} do_test shell1-3.20.4 { # too many arguments catchcmd "test.db" ".restore FOO BAR BAD" } {1 {Error: unknown command or invalid arguments: "restore". Enter ".help" for help}} # .schema ?TABLE? Show the CREATE statements # If TABLE specified, only show tables matching # LIKE pattern TABLE. do_test shell1-3.21.1 { catchcmd "test.db" ".schema" } {0 {}} do_test shell1-3.21.2 { catchcmd "test.db" ".schema FOO" } {0 {}} do_test shell1-3.21.3 { # too many arguments catchcmd "test.db" ".schema FOO BAD" } {1 {Error: unknown command or invalid arguments: "schema". Enter ".help" for help}} # .separator STRING Change separator used by output mode and .import do_test shell1-3.22.1 { catchcmd "test.db" ".separator" } {1 {Error: unknown command or invalid arguments: "separator". Enter ".help" for help}} do_test shell1-3.22.2 { catchcmd "test.db" ".separator FOO" } {0 {}} do_test shell1-3.22.3 { # too many arguments catchcmd "test.db" ".separator FOO BAD" } {1 {Error: unknown command or invalid arguments: "separator". Enter ".help" for help}} # .show Show the current values for various settings do_test shell1-3.23.1 { set res [catchcmd "test.db" ".show"] list [regexp {echo:} $res] \ [regexp {explain:} $res] \ [regexp {headers:} $res] \ [regexp {mode:} $res] \ [regexp {nullvalue:} $res] \ [regexp {output:} $res] \ [regexp {separator:} $res] \ [regexp {width:} $res] } {1 1 1 1 1 1 1 1} do_test shell1-3.23.2 { # too many arguments catchcmd "test.db" ".show BAD" } {1 {Error: unknown command or invalid arguments: "show". Enter ".help" for help}} # .tables ?TABLE? List names of tables # If TABLE specified, only list tables matching # LIKE pattern TABLE. do_test shell1-3.24.1 { catchcmd "test.db" ".tables" } {0 {}} do_test shell1-3.24.2 { catchcmd "test.db" ".tables FOO" } {0 {}} do_test shell1-3.24.3 { # too many arguments catchcmd "test.db" ".tables FOO BAD" } {1 {Error: unknown command or invalid arguments: "tables". Enter ".help" for help}} # .timeout MS Try opening locked tables for MS milliseconds do_test shell1-3.25.1 { catchcmd "test.db" ".timeout" } {1 {Error: unknown command or invalid arguments: "timeout". Enter ".help" for help}} do_test shell1-3.25.2 { catchcmd "test.db" ".timeout zzz" # this should be treated the same as a '0' timeout } {0 {}} do_test shell1-3.25.3 { catchcmd "test.db" ".timeout 1" } {0 {}} do_test shell1-3.25.4 { # too many arguments catchcmd "test.db" ".timeout 1 BAD" } {1 {Error: unknown command or invalid arguments: "timeout". Enter ".help" for help}} # .width NUM NUM ... Set column widths for "column" mode do_test shell1-3.26.1 { catchcmd "test.db" ".width" } {1 {Error: unknown command or invalid arguments: "width". Enter ".help" for help}} do_test shell1-3.26.2 { catchcmd "test.db" ".width xxx" # this should be treated the same as a '0' width for col 1 } {0 {}} do_test shell1-3.26.3 { catchcmd "test.db" ".width xxx yyy" # this should be treated the same as a '0' width for col 1 and 2 } {0 {}} do_test shell1-3.26.4 { catchcmd "test.db" ".width 1 1" # this should be treated the same as a '1' width for col 1 and 2 } {0 {}} # .timer ON|OFF Turn the CPU timer measurement on or off do_test shell1-3.27.1 { catchcmd "test.db" ".timer" } {1 {Error: unknown command or invalid arguments: "timer". Enter ".help" for help}} do_test shell1-3.27.2 { catchcmd "test.db" ".timer ON" } {0 {}} do_test shell1-3.27.3 { catchcmd "test.db" ".timer OFF" } {0 {}} do_test shell1-3.27.4 { # too many arguments catchcmd "test.db" ".timer OFF BAD" } {1 {Error: unknown command or invalid arguments: "timer". Enter ".help" for help}} # |
Changes to tool/shell2.test.
︙ | ︙ | |||
17 18 19 20 21 22 23 | # Test plan: # # shell2-1.*: Misc. test of various tickets and reported errors. # package require sqlite3 | | | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # Test plan: # # shell2-1.*: Misc. test of various tickets and reported errors. # package require sqlite3 set CLI "./sqlite3" proc do_test {name cmd expected} { puts -nonewline "$name ..." set res [uplevel $cmd] if {$res eq $expected} { puts Ok } else { |
︙ | ︙ | |||
41 42 43 44 45 46 47 | } proc catchsql {sql} { set rc [catch {uplevel [list db eval $sql]} msg] list $rc $msg } | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | } proc catchsql {sql} { set rc [catch {uplevel [list db eval $sql]} msg] list $rc $msg } proc catchcmd {db {cmd ""}} { global CLI set out [open cmds.txt w] puts $out $cmd close $out set line "exec $CLI $db < cmds.txt" set rc [catch { eval $line } msg] list $rc $msg |
︙ | ︙ |
Added tool/shell3.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | # 2009 Dec 16 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # # The focus of this file is testing the CLI shell tool. # # $Id: shell2.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $ # # Test plan: # # shell3-1.*: Basic tests for running SQL statments from command line. # shell3-2.*: Basic tests for running SQL file from command line. # package require sqlite3 set CLI "./sqlite3" proc do_test {name cmd expected} { puts -nonewline "$name ..." set res [uplevel $cmd] if {$res eq $expected} { puts Ok } else { puts Error puts " Got: $res" puts " Expected: $expected" exit } } proc execsql {sql} { uplevel [list db eval $sql] } proc catchsql {sql} { set rc [catch {uplevel [list db eval $sql]} msg] list $rc $msg } proc catchcmd {db {cmd ""}} { global CLI set out [open cmds.txt w] puts $out $cmd close $out set line "exec $CLI $db < cmds.txt" set rc [catch { eval $line } msg] list $rc $msg } file delete -force test.db test.db.journal sqlite3 db test.db #---------------------------------------------------------------------------- # shell3-1.*: Basic tests for running SQL statments from command line. # # Run SQL statement from command line do_test shell3-1.1 { file delete -force foo.db set rc [ catchcmd "foo.db \"CREATE TABLE t1(a);\"" ] set fexist [file exist foo.db] list $rc $fexist } {{0 {}} 1} do_test shell3-1.2 { catchcmd "foo.db" ".tables" } {0 t1} do_test shell3-1.3 { catchcmd "foo.db \"DROP TABLE t1;\"" } {0 {}} do_test shell3-1.4 { catchcmd "foo.db" ".tables" } {0 {}} do_test shell3-1.5 { catchcmd "foo.db \"CREATE TABLE t1(a); DROP TABLE t1;\"" } {0 {}} do_test shell3-1.6 { catchcmd "foo.db" ".tables" } {0 {}} do_test shell3-1.7 { catchcmd "foo.db \"CREATE TABLE\"" } {1 {Error: near "TABLE": syntax error}} #---------------------------------------------------------------------------- # shell3-2.*: Basic tests for running SQL file from command line. # # Run SQL file from command line do_test shell3-2.1 { file delete -force foo.db set rc [ catchcmd "foo.db" "CREATE TABLE t1(a);" ] set fexist [file exist foo.db] list $rc $fexist } {{0 {}} 1} do_test shell3-2.2 { catchcmd "foo.db" ".tables" } {0 t1} do_test shell3-2.3 { catchcmd "foo.db" "DROP TABLE t1;" } {0 {}} do_test shell3-2.4 { catchcmd "foo.db" ".tables" } {0 {}} do_test shell3-2.5 { catchcmd "foo.db" "CREATE TABLE t1(a); DROP TABLE t1;" } {0 {}} do_test shell3-2.6 { catchcmd "foo.db" ".tables" } {0 {}} do_test shell3-2.7 { catchcmd "foo.db" "CREATE TABLE" } {1 {Error: incomplete SQL: CREATE TABLE}} |