{"id":18044652,"url":"https://github.com/groonga/grntest","last_synced_at":"2025-10-20T00:33:29.399Z","repository":{"id":2616087,"uuid":"3600151","full_name":"groonga/grntest","owner":"groonga","description":"A testing framework for Groonga.","archived":false,"fork":false,"pushed_at":"2025-08-12T07:57:51.000Z","size":771,"stargazers_count":5,"open_issues_count":2,"forks_count":8,"subscribers_count":20,"default_branch":"main","last_synced_at":"2025-08-28T10:54:03.778Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://groonga.org/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/groonga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-03-02T07:37:10.000Z","updated_at":"2025-08-12T07:57:54.000Z","dependencies_parsed_at":"2024-04-12T15:25:17.231Z","dependency_job_id":"a0c882c3-4002-4150-8b6f-408bd97c24e6","html_url":"https://github.com/groonga/grntest","commit_stats":{"total_commits":785,"total_committers":6,"mean_commits":"130.83333333333334","dds":"0.16815286624203818","last_synced_commit":"526539b6ffd1942e631ad025a05cef9e5952f27d"},"previous_names":[],"tags_count":83,"template":false,"template_full_name":null,"purl":"pkg:github/groonga/grntest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/groonga%2Fgrntest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/groonga%2Fgrntest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/groonga%2Fgrntest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/groonga%2Fgrntest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/groonga","download_url":"https://codeload.github.com/groonga/grntest/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/groonga%2Fgrntest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275194029,"owners_count":25421442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-15T02:00:09.272Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-30T18:10:10.464Z","updated_at":"2025-10-20T00:33:24.357Z","avatar_url":"https://github.com/groonga.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# README\n\n[![Gem Version](https://badge.fury.io/rb/grntest.svg)](http://badge.fury.io/rb/grntest)\n\n## Name\n\ngrntest\n\n## Description\n\nGrntest is a testing framework for Groonga. You can write a test for\nGroonga by writing Groonga commands and expected result.\n\n## Install\n\n```\n% gem install grntest\n```\n\n## Basic usage\n\nWrite a test script that extension is `.test`. Here is a sample test\nscript `select.test`:\n\n```\ntable_create Users TABLE_HASH_KEY ShortText\n\nload --table Users\n[\n{\"_key\": \"Alice\"},\n{\"_key\": \"Bob\"}\n]\n\nselect Users --query '_key:Alice'\n```\n\nRun `grntest` with `select.test` as command line argument:\n\n```\n% grntest select.test\nN\n================================================================================\n.\n  select                                                   0.3866s [not checked]\n================================================================================\ntable_create Users TABLE_HASH_KEY ShortText\n[[0,0.0,0.0],true]\nload --table Users\n[\n{\"_key\": \"Alice\"},\n{\"_key\": \"Bob\"}\n]\n[[0,0.0,0.0],2]\nselect Users --query '_key:Alice'\n[[0,0.0,0.0],[[[1],[[\"_id\",\"UInt32\"],[\"_key\",\"ShortText\"]],[1,\"Alice\"]]]]\n================================================================================\n\n\n  tests/sec | tests     | passes    | failures  | leaked    | !checked  |\n       2.57 |         1 |         0 |         0 |         0 |         1 |\n0% passed in 0.3885s.\n```\n\nIt generates `select.actual` file that contains actual result. If it\nis expected result, rename it to `select.expected`:\n\n```\n% mv select.actual select.expected\n```\n\nRun `grntest` again:\n\n```\n% grntest select.test\n.\n\n  tests/sec | tests     | passes    | failures  | leaked    | !checked  |\n       5.76 |         1 |         1 |         0 |         0 |         0 |\n100% passed in 0.1736s.\n```\n\nIt compares actual result and content of `select.expected` and\nreporots compared result. If they are the same contnet, `grntest`\nreports success. If they are not the same content, `grntest` reports\nfailure and show diff of them.\n\nChange `--query '_key:Alice'` to `--query '_key:Bob`' in\n`select.test`:\n\n```\ntable_create Users TABLE_HASH_KEY ShortText\n\nload --table Users\n[\n{\"_key\": \"Alice\"},\n{\"_key\": \"Bob\"}\n]\n\nselect Users --query '_key:Bob'\n```\n\nRun `grntest` again:\n\n```\n% grntest select.test\nF\n================================================================================\n.\n  select                                                        0.1767s [failed]\n================================================================================\n--- (expected)\n+++ (actual)\n@@ -6,5 +6,5 @@\n {\"_key\": \"Bob\"}\n ]\n [[0,0.0,0.0],2]\n-select Users --query '_key:Alice'\n-[[0,0.0,0.0],[[[1],[[\"_id\",\"UInt32\"],[\"_key\",\"ShortText\"]],[1,\"Alice\"]]]]\n+select Users --query '_key:Bob'\n+[[0,0.0,0.0],[[[1],[[\"_id\",\"UInt32\"],[\"_key\",\"ShortText\"]],[2,\"Bob\"]]]]\n================================================================================\n\n\n  tests/sec | tests     | passes    | failures  | leaked    | !checked  |\n       4.65 |         1 |         0 |         1 |         0 |         0 |\n0% passed in 0.2153s.\n```\n\nIt says the expected result that is read from `select.expected` and\nthe actual result are not same. And the difference of them is shown in\nunified diff format. It is helpful to debug the test.\n\n`select.reject` file is generated on failure. It contains the actual\nresult. If the actual result is the expected result, rename it to\n`select.expected`.\n\n```\n% mv select.reject select.expected\n```\n\nRun `grntest` again:\n\n```\n% grntest select.test\n.\n\n  tests/sec | tests     | passes    | failures  | leaked    | !checked  |\n       6.20 |         1 |         1 |         0 |         0 |         0 |\n100% passed in 0.1613s.\n```\n\nThe test is succeeded again.\n\n## Advanced usage\n\nThere are more useful features. They are not needed for normal\nusers but they are very useful for advanced users.\n\nThere are advanced features:\n\n* Comment\n* Continuation line\n* Directives\n\n### Comment\n\nGroonga supports comment line by `#`.\n\nExample:\n\n```\n# This line is comment line.\nselect Users\n```\n\nGrntest also supports the syntax. You can use `#` as comment mark.\n\n### Continuation line\n\nYou can break a long line by escaping new line with `\\`.\n\nExample:\n\n```\nselect Users \\\n  --match_columns name \\\n  --query Ken\n```\n\nThe command is processed as the following command:\n\n```\nselect Users  --match_columns name   --query Ken\n```\n\nYou can make your test readable with this feature.\n\nGroogna doesn't support this feature.\n\n### Directives\n\nGrntest supports directives that control grntest behavior.\n\nHere is directive syntax:\n\n```\n#@NAME [ARGUMENTS...]\n```\n\nHere are available `NAME` s:\n\n* `disable-logging`\n* `enable-logging`\n* `suggest-create-dataset`\n* `include`\n* `copy-path`\n* `long-timeout`\n* `on-error`\n* `omit`\n* `add-important-log-levels`\n* `remove-important-log-levels`\n* `sleep`\n* `collect-query-log`\n\n`ARGUMENTS...` are depends on directive. A directive doesn't require\nany arguments but a directive requires arguments.\n\n#### `disable-logging`\n\nUsage:\n\n```\n#@disable-logging\n```\n\nIt disables logging executed command and executed result until\n`enable-logging` directive is used. It is useful for executing\ncommands that isn't important for test.\n\nExample:\n\n```\n#@disable-logging\nload --table Users\n[\n{\"_key\": \"User1\"},\n{\"_key\": \"...\"},\n{\"_key\": \"User9999999\"}\n]\n#@enable-logging\n\nselect Users --query _key:User29\n```\n\nSee also: `enable-logging`\n\n#### `enable-logging`\n\nUsage:\n\n```\n#@enable-logging\n```\n\nIt enables logging that is disabled by `disable-logging` directive.\n\nSee also: `disable-logging`\n\n#### `suggest-create-dataset`\n\nUsage:\n\n```\n#@suggest-create-dataset DATASET_NAME\n```\n\nIt creates dataset `DATASET_NAME` for suggest feature. It is useful\nfor testing suggest feature.\n\nExample:\n\n```\n#@suggest-create-dataset rurema\nload --table event_rurema --each 'suggest_preparer(_id, type, item, sequence, time, pair_rurema)'\n[\n[\"sequence\", \"time\", \"item\", \"type\"],\n[\"21e80fd5e5bc2126469db1c927b7a48fb3353dd9\",1312134098.0,\"f\",null],\n[\"21e80fd5e5bc2126469db1c927b7a48fb3353dd9\",1312134105.0,\"er\",null],\n[\"21e80fd5e5bc2126469db1c927b7a48fb3353dd9\",1312134106.0,\"erb\",null],\n[\"21e80fd5e5bc2126469db1c927b7a48fb3353dd9\",1312134107.0,\"erb\",\"submit\"]\n]\n```\n\nSee also: `--groonga-suggest-create-dataset` option\n\n#### `include`\n\nUsage:\n\n```\n#@include SUB_TEST_FILE_PATH\n```\n\nIt includes `SUB_TEST_FILE_PATH` content. It is useful for sharing\ncommands by many tests.\n\nYou can use `include` in included file. It means that an included file\nis processed in the same way as a test file.\n\nIf `SUB_TEST_FILE_PATH` is relative path, `SUB_TEST_FILE_PATH` is\nfound from base directory. Base directory can be specified by\n`--base-directory` option.\n\nExample:\n\ninit.grn:\n\n```\n#@disable-logging\n#@include ddl.grn\n#@include data.grn\n#@enable-logging\n```\n\nddl.grn:\n\n```\ntable_create Users TABLE_HASH_KEY ShortText\n```\n\ndata.grn:\n\n```\nload --table Users\n[\n[\"_key\"],\n[\"Alice\"],\n[\"Bob\"]\n]\n```\n\nuser.test:\n\n```\n#@include init.grn\nselect Users --query _key:Alice\n```\n\nSee also: `--base-directory` option\n\n#### `copy-path`\n\nUsage:\n\n```\n#@copy-path SOURCE DESTINATION\n```\n\nIt copies a path from `SOURCE` to `DESTINATION`. You can use it for\nboth file and directory. It is useful for using fixture data.\n\nYou can use `#{db_path}` in `SOURCE` and `DESTINATION`. `#{db_path}`\nis expanded to the path of the database.\n\nExample:\n\n```\n#@copy-path fixture/query_expander/tsv/japanese_synonyms.tsv tmp/synonyms.tsv\nregister \"query_expanders/tsv\"\n```\n\n#### `long-timeout`\n\nUsage:\n\n```\n#@long-timeout TIMEOUT\n```\n\nIt specifies a timeout for commands that may take long time.\n`TIMEOUT` must be a number or `default`. If you specify `default` as\n`TIMEOUT`, the default timeout is used. The default timeout is 180\nseconds.\n\nHere are the commands that may take long time:\n\n* `column_create`\n* `register`\n\nExample:\n\n```\n# Wait 300 seconds until commands that may take long time output their results\n#@long-timeout 300\ncolumn_create Lexicon users_name COLUMN_INDEX Users name\n# Reset custom timeout for commands that may take long time.\n#@long-timeout default\n```\n\n#### `on-error`\n\nUsage:\n\n```\n#@on-error ACTION\n```\n\nIt specifies a action on error. `ACTION` must be `default` or\n`omit`. If you specify `default` as `ACTION`, the running test is\ncontinued. If you specify `omit` as `ACTION`, the running test is\naborted and the running test is marked as omitted.\n\nExample:\n\n```\n# Omit this test if TokenKyTea tokenizer isn't available.\n#@on-error omit\nregister tokenizers/kytea\n# Don't omit this test when any error is occurred in the following commands.\n#@on-error default\n```\n\n#### `omit`\n\nUsage:\n\n```\n#@omit REASON\n```\n\nOmit the test with `REASON`.\n\nExample:\n\n```\n# Omit this test until the feature is implemented.\n#@omit \"This feature is not implemented yet.\"\nnew_excelent_command\n```\n\n#### `add-important-log-levels`\n\nUsage:\n\n```\n#@add-important-log-levels LEVEL_1 LEVEL_2 ...\n```\n\nAdd `LEVEL_N` to important log level list. grntest outputs log\nmessages when their log level is included in important log level\nlist.\n\nThe default important log level list has the following log levels:\n\n  * `emergency`\n  * `alert`\n  * `critical`\n  * `error`\n  * `warning`\n  * `notice`\n\nIf you want to test log messages for `info`, `debug` or `dump` log\nlevels, you need to add the log level to important log level list.\n\nExample:\n\n```\n# Enable logs for debug level\nlog_level --level debug\n# Collect debug level log messages\n#@add-important-log-levels debug\nlog_put --level debug --message \"This is a message\"\n# The following messages is collected by grntest\n#|d| This is a message\n```\n\n#### `remove-important-log-levels`\n\nUsage:\n\n```\n#@remove-important-log-levels LEVEL_1 LEVEL_2 ...\n```\n\nRemove `LEVEL_N` from important log level list. grntest outputs log\nmessages when their log level is included in important log level\nlist.\n\nThe default important log level list has the following log levels:\n\n  * `emergency`\n  * `alert`\n  * `critical`\n  * `error`\n  * `warning`\n  * `notice`\n\nYou can remove them from important log level list. You can only remove\nlog levels added by `add-important-log-levels`.\n\nExample:\n\n```\n# Enable logs for debug level\nlog_level --level debug\n# Collect debug level log messages\n#@add-important-log-levels debug\nlog_put --level debug --message \"This is a message\"\n# The following messages is collected by grntest\n#|d| This is a message\n\n# Disable collecting debug level log messages\n#@remove-important-log-levels debug\nlog_put --level debug --message \"This is a message\"\n# No message is collected by grntest\n```\n\n#### `sleep`\n\nUsage:\n\n```\n#@sleep SECOND\n```\n\nIt stops execution while the specified seconds.\n\nExample:\n\n```\nload --table Users\n[\n{\"_key\": \"User1\"}\n]\n#@sleep 1.5\n# Run select after 1.5 sec.\nselect Users --query _key:User1\n```\n\n#### `collect-query-log`\n\nUsage:\n\n```\n#@collect-query-log [true|false]\n```\n\nIt collects messages from query log and prints them.\n\nExample:\n\n```\n#@collect-query-log true\nselect Users --query _key:User1\n#@collect-query-log false\n```\n\n## Options\n\nGrntest has many options. You don't need to specify many of them\nbecause they use suitable default values.\n\nThis section describes some important options. You can see all options\nby `grntest --help`. You will find many usuful features from it.\n\n### `--test`\n\nUsage:\n\n```\n% grntest --test TEST_NAME ...\n% grntest --test /TEST_NAME_REGEXP/ ...\n% grntest --test TEST_NAME1 --test TEST_NAME2 ...\n% grntest --test /TEST_NAME_REGEXP1/ --test /TEST_NAME_REGEXP2/ ...\n```\n\n`--test` option specifies tests that should be ran. It is useful when\nyou are interested in only one test.\n\nFor example, the following command line runs only `vector-geo-point`\ntest.\n\n```\n% grntest --test vector-geo-point ...\n```\n\nYou can use `--test` option multiple times to run only multiple\ninterested tests.\n\nFor example, the following command line runs only `vector-geo-point`\nand `hash` tests.\n\n```\n% grntest --test vector-geo-point --test hash ...\n```\n\nYou can use regular expression to select tests by `/.../` syntax.\n\nFor example, the following command line runs tests that have `geo` in\nits name.\n\n```\n% grntest --test /geo/ ...\n```\n\nYou can also use multiple --test options with regular expression.\n\nSee also: `--exclude-test` option\n\n### `--exclude-test`\n\n### `--test-suite`\n\n### `--exclude-test-suite`\n\n### `--gdb`\n\n### `--keep-database`\n\n### `--n-workers`\n\n`--n-workers` option is very useful. You can run many test scripts at\nonce. Tests are finished quickly. You should specify one or more\ndirectories that contain many test scripts. If you have only a test\nscript, `--n-workers` is not effective.\n\nHere is a sample command line to use `--n-workers`:\n\n```\n% grntest --n-workers 4 test/function/suite/suggest\n  tests/sec | tests     | passes    | failures  | leaked    | !checked  |\n[0]                                                                   [finished]\n       9.95 |         5 |         5 |         0 |         0 |         0 |       \n[1]                                                                   [finished]\n       9.22 |         4 |         4 |         0 |         0 |         0 |       \n[2]                                                                   [finished]\n       9.11 |         4 |         4 |         0 |         0 |         0 |       \n[3]                                                                   [finished]\n      10.10 |         5 |         5 |         0 |         0 |         0 |       \n|-----------------------------------------------------------------------| [100%]\n\n  tests/sec | tests     | passes    | failures  | leaked    | !checked  |\n      34.61 |        18 |        18 |         0 |         0 |         0 |\n100% passed in 0.5201s.\n```\n\n### `--base-directory`\n\n### `--database=PATH`\n\nUsage:\n\n```\n% grntest --database /PATH/TO/EXISTING/DATABASE ...\n```\n\n`--database` option specifies an existing database that is used for\ntest. Normally, grntest uses a new empty database for test.\n\n`--database` option is very useful for testing against existing\ndatabase.\n\n### `--groonga`\n\n### `--groonga-httpd`\n\n### `--groonga-suggest-create-dataset`\n\n### `--interface`\n\n### `--output-type`\n\n### `--testee`\n\n## Examples\n\nSee [test/command/ directory in Groonga's\nsource](https://github.com/groonga/groonga/tree/master/test/command). It\nhas many test scripts and uses many useful features. They will help you.\n\n## Dependencies\n\n* Ruby\n* msgpack gem\n\n## Mailing list\n\n* English: [groonga-talk@lists.sourceforge.net](https://lists.sourceforge.net/lists/listinfo/groonga-talk)\n* Japanese: [groonga-dev@lists.sourceforge.jp](http://lists.sourceforge.jp/mailman/listinfo/groonga-dev)\n\n## Thanks\n\n* ...\n\n## Authors\n\n* Kouhei Sutou \\\u003ckou@clear-code.com\\\u003e\n* Haruka Yoshihara \\\u003cyoshihara@clear-code.com\\\u003e\n\n## License\n\nGPLv3 or later. See doc/text/gpl-3.0.txt for details.\n\n(Kouhei Sutou has a right to change the license including contributed\npatches.)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgroonga%2Fgrntest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgroonga%2Fgrntest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgroonga%2Fgrntest/lists"}