diff --git a/CHANGELOG.md b/CHANGELOG.md index e615195..ae5de38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## [0.17.0] - 2023-09-19 + +* Support environment variables substituion for SQL and system commands. + For compatibility, this feature is by default disabled, and can be enabled by adding `control substitution on` to the test file. + ``` + control substitution on + + query TTTT + SELECT + '$foo' -- short + , '${foo}' -- long + , '${bar:default}' -- default value + , '${bar:$foo-default}' -- recursive default value + FROM baz; + ---- + ... + ``` + + Besides, there's a special variable `$__TEST_DIR__` which is the path to a temporary directory specific to the current test case. + This can be helpful if you need to manipulate some external resources during the test. + ``` + control substitution on + + statement ok + COPY (SELECT * FROM foo) TO '$__TEST_DIR__/foo.txt'; + + system ok + echo "foo" > "$__TEST_DIR__/foo.txt" + ``` + + Changes: + - (parser) **Breaking change**: Add `Control::Substitution`. Mark `Control` as `#[non_exhaustive]`. + - (runner) **Breaking change**: Remove `enable_testdir`. For migration, one should now enable general substitution by the `control` statement and use a dollar-prefixed `$__TEST_DIR__`. + ## [0.16.0] - 2023-09-15 * Support running external system commands with the syntax below. This is useful for manipulating some external resources during the test. diff --git a/Cargo.lock b/Cargo.lock index 0dedb65..731b785 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -41,9 +41,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "0f2135563fb5c609d2b2b87c1e8ce7bc41b0b45430fa9661f457981503dd5bf0" dependencies = [ "memchr", ] @@ -65,24 +65,23 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46" [[package]] name = "anstyle-parse" @@ -104,9 +103,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -114,9 +113,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "arrayvec" @@ -126,13 +125,13 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-trait" -version = "0.1.71" +version = "0.1.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a564d521dd56509c4c47480d00b80ee55f7e385ae48db5744c67ad50c92d2ebf" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.37", ] [[package]] @@ -143,9 +142,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", @@ -158,9 +157,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.2" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "bitflags" @@ -170,9 +169,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "bitvec" @@ -242,9 +241,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytecheck" @@ -276,15 +275,18 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -294,35 +296,33 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", - "time", "wasm-bindgen", - "winapi", + "windows-targets 0.48.5", ] [[package]] name = "clap" -version = "4.3.11" +version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1640e5cc7fb47dbb8338fd471b105e7ed6c3cb2aeb00c2e067127ffd3764a05d" +checksum = "b1d7b8d5ec32af0fadc644bf1fd509a688c2103b185644bb1e29d164e0703136" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.3.11" +version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c59138d527eeaf9b53f35a77fcc1fad9d883116070c63d5de1c7dc7b00c72b" +checksum = "5179bb514e4d7c2051749d8fcefa2ed6d06a9f4e6d69faf3805f5d80b8cf8d56" dependencies = [ "anstream", "anstyle", @@ -332,21 +332,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.2" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" +checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.37", ] [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" [[package]] name = "colorchoice" @@ -411,9 +411,9 @@ dependencies = [ [[package]] name = "educe" -version = "0.4.22" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "079044df30bb07de7d846d41a184c4b00e66ebdac93ee459253474f3a47e50ae" +checksum = "0f0042ff8246a363dbe77d2ceedb073339e85a804b9a47636c6e016a9a32c05f" dependencies = [ "enum-ordinalize", "proc-macro2", @@ -423,9 +423,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "encode_unicode" @@ -443,7 +443,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.37", ] [[package]] @@ -467,9 +467,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" dependencies = [ "errno-dragonfly", "libc", @@ -494,12 +494,21 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "fastrand" -version = "1.9.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" + +[[package]] +name = "finl_unicode" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fs-err" @@ -569,7 +578,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.37", ] [[package]] @@ -620,14 +629,14 @@ checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] name = "gimli" -version = "0.27.3" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "glob" @@ -719,26 +728,6 @@ dependencies = [ "hashbrown 0.14.0", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "is-terminal" version = "0.4.9" @@ -746,7 +735,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.3", + "rustix", "windows-sys 0.48.0", ] @@ -761,9 +750,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" @@ -782,9 +771,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "libtest-mimic" @@ -799,15 +788,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - -[[package]] -name = "linux-raw-sys" -version = "0.4.3" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" +checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" [[package]] name = "lock_api" @@ -821,9 +804,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "md-5" @@ -836,9 +819,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" [[package]] name = "miniz_oxide" @@ -856,7 +839,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.48.0", ] @@ -868,9 +851,9 @@ checksum = "d906846a98739ed9d73d66e62c2641eef8321f1734b7a1156ab045a0248fb2b3" [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", @@ -889,9 +872,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] @@ -908,9 +891,9 @@ dependencies = [ [[package]] name = "object" -version = "0.31.1" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] @@ -947,7 +930,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.48.1", + "windows-targets 0.48.5", ] [[package]] @@ -987,9 +970,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -999,9 +982,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "postgres" -version = "0.19.5" +version = "0.19.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bed5017bc2ff49649c0075d0d7a9d676933c1292480c1d137776fb205b5cd18" +checksum = "7915b33ed60abc46040cbcaa25ffa1c7ec240668e0477c4f3070786f5916d451" dependencies = [ "bytes", "fallible-iterator", @@ -1013,20 +996,21 @@ dependencies = [ [[package]] name = "postgres-derive" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "070ffaa78859c779b19f9358ce035480479cf2619e968593ffbe72abcb6e0fcf" +checksum = "83145eba741b050ef981a9a1838c843fa7665e154383325aa8b440ae703180a2" dependencies = [ + "heck", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.37", ] [[package]] name = "postgres-protocol" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b7fa9f396f51dffd61546fd8573ee20592287996568e6175ceb0f8699ad75d" +checksum = "49b6c5ef183cd3ab4ba005f1ca64c21e8bd97ce4699cfea9e8d9a2c4958ca520" dependencies = [ "base64", "byteorder", @@ -1042,9 +1026,9 @@ dependencies = [ [[package]] name = "postgres-types" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f028f05971fe20f512bcc679e2c10227e57809a3af86a7606304435bc8896cd6" +checksum = "8d2234cdee9408b523530a9b6d2d6b373d1db34f6a8e51dc03ded1828d7fb67c" dependencies = [ "bytes", "chrono", @@ -1080,9 +1064,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.64" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] @@ -1107,6 +1091,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quick-junit" version = "0.3.3" @@ -1132,9 +1122,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.29" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -1186,9 +1176,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.1" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" dependencies = [ "aho-corasick", "memchr", @@ -1198,9 +1188,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.2" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83d3daa6976cffb758ec878f108ba0e062a45b2d6ca3a2cca965338855476caf" +checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" dependencies = [ "aho-corasick", "memchr", @@ -1209,9 +1199,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "rend" @@ -1252,14 +1242,12 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.30.0" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0446843641c69436765a35a5a77088e28c2e6a12da93e84aa3ab1cd4aa5a042" +checksum = "a4c4216490d5a413bc6d10fa4742bd7d4955941d062c0ef873141d6b0e7b30fd" dependencies = [ "arrayvec", "borsh", - "bytecheck", - "byteorder", "bytes", "num-traits", "postgres", @@ -1278,42 +1266,40 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.37.23" +version = "0.38.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" +checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.0", "errno", - "io-lifetimes", "libc", - "linux-raw-sys 0.3.8", + "linux-raw-sys", "windows-sys 0.48.0", ] [[package]] -name = "rustix" -version = "0.38.3" +name = "rusty-fork" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac5ffa1efe7548069688cd7028f32591853cd7b5b756d41bcffd2353e4fc75b4" +checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" dependencies = [ - "bitflags 2.3.3", - "errno", - "libc", - "linux-raw-sys 0.4.3", - "windows-sys 0.48.0", + "fnv", + "quick-error", + "tempfile", + "wait-timeout", ] [[package]] name = "ryu" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "seahash" @@ -1323,29 +1309,29 @@ checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] name = "serde" -version = "1.0.171" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.171" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.37", ] [[package]] name = "serde_json" -version = "1.0.100" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1e14e89be7aa4c4b78bdbdc9eb5bf8517829a600ae8eaa39a6e1d960b5185c" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -1386,15 +1372,15 @@ checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] @@ -1407,19 +1393,9 @@ checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "socket2" -version = "0.4.9" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "socket2" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" dependencies = [ "libc", "windows-sys 0.48.0", @@ -1427,7 +1403,7 @@ dependencies = [ [[package]] name = "sqllogictest" -version = "0.16.0" +version = "0.17.0" dependencies = [ "async-trait", "educe", @@ -1442,6 +1418,7 @@ dependencies = [ "pretty_assertions", "regex", "similar", + "subst", "tempfile", "thiserror", "tracing", @@ -1449,7 +1426,7 @@ dependencies = [ [[package]] name = "sqllogictest-bin" -version = "0.16.0" +version = "0.17.0" dependencies = [ "anyhow", "async-trait", @@ -1470,7 +1447,7 @@ dependencies = [ [[package]] name = "sqllogictest-engines" -version = "0.16.0" +version = "0.17.0" dependencies = [ "async-trait", "bytes", @@ -1491,10 +1468,11 @@ dependencies = [ [[package]] name = "stringprep" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1" +checksum = "bb41d74e231a107a1b4ee36bd1214b11285b77768d2e3824aedafa988fd36ee6" dependencies = [ + "finl_unicode", "unicode-bidi", "unicode-normalization", ] @@ -1505,6 +1483,16 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "subst" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca1318e5d6716d6541696727c88d9b8dfc8cfe6afd6908e186546fd4af7f5b98" +dependencies = [ + "memchr", + "unicode-width", +] + [[package]] name = "subtle" version = "2.5.0" @@ -1524,9 +1512,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.25" +version = "2.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" dependencies = [ "proc-macro2", "quote", @@ -1541,23 +1529,22 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.6.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ - "autocfg", "cfg-if", "fastrand", "redox_syscall", - "rustix 0.37.23", + "rustix", "windows-sys 0.48.0", ] [[package]] name = "termcolor" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" dependencies = [ "winapi-util", ] @@ -1567,27 +1554,28 @@ name = "tests" version = "0.1.0" dependencies = [ "regex", + "rusty-fork", "sqllogictest", ] [[package]] name = "thiserror" -version = "1.0.43" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" +checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.43" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" +checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.37", ] [[package]] @@ -1599,17 +1587,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -1627,11 +1604,10 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.1" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ - "autocfg", "backtrace", "bytes", "libc", @@ -1639,7 +1615,7 @@ dependencies = [ "num_cpus", "pin-project-lite", "signal-hook-registry", - "socket2 0.4.9", + "socket2", "tokio-macros", "windows-sys 0.48.0", ] @@ -1652,14 +1628,14 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.37", ] [[package]] name = "tokio-postgres" -version = "0.7.8" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e89f6234aa8fd43779746012fcf53603cdb91fdd8399aa0de868c2d56b6dde1" +checksum = "d340244b32d920260ae7448cb72b6e238bddc3d4f7603394e7dd46ed8e48f5b8" dependencies = [ "async-trait", "byteorder", @@ -1674,9 +1650,11 @@ dependencies = [ "pin-project-lite", "postgres-protocol", "postgres-types", - "socket2 0.5.3", + "rand", + "socket2", "tokio", "tokio-util", + "whoami", ] [[package]] @@ -1722,7 +1700,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.37", ] [[package]] @@ -1736,9 +1714,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" @@ -1748,9 +1726,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.10" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -1775,9 +1753,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be" +checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" [[package]] name = "version_check" @@ -1786,10 +1764,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +name = "wait-timeout" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] [[package]] name = "wasi" @@ -1818,7 +1799,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.37", "wasm-bindgen-shared", ] @@ -1840,7 +1821,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.37", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1851,6 +1832,26 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +[[package]] +name = "web-sys" +version = "0.3.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "whoami" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" +dependencies = [ + "wasm-bindgen", + "web-sys", +] + [[package]] name = "winapi" version = "0.3.9" @@ -1888,7 +1889,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.1", + "windows-targets 0.48.5", ] [[package]] @@ -1906,7 +1907,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.1", + "windows-targets 0.48.5", ] [[package]] @@ -1926,17 +1927,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -1947,9 +1948,9 @@ checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" @@ -1959,9 +1960,9 @@ checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" @@ -1971,9 +1972,9 @@ checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" @@ -1983,9 +1984,9 @@ checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" @@ -1995,9 +1996,9 @@ checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" @@ -2007,9 +2008,9 @@ checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" @@ -2019,9 +2020,9 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "wyz" diff --git a/Cargo.toml b/Cargo.toml index 02e22d3..74882c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,9 @@ [workspace] +resolver = "2" members = ["sqllogictest", "sqllogictest-bin", "sqllogictest-engines", "tests"] [workspace.package] -version = "0.16.0" +version = "0.17.0" edition = "2021" homepage = "https://github.com/risinglightdb/sqllogictest-rs" keywords = ["sql", "database", "parser", "cli"] diff --git a/sqllogictest-bin/Cargo.toml b/sqllogictest-bin/Cargo.toml index fd30801..c3f7c33 100644 --- a/sqllogictest-bin/Cargo.toml +++ b/sqllogictest-bin/Cargo.toml @@ -24,8 +24,8 @@ glob = "0.3" itertools = "0.11" quick-junit = { version = "0.3" } rand = "0.8" -sqllogictest = { path = "../sqllogictest", version = "0.16" } -sqllogictest-engines = { path = "../sqllogictest-engines", version = "0.16" } +sqllogictest = { path = "../sqllogictest", version = "0.17" } +sqllogictest-engines = { path = "../sqllogictest-engines", version = "0.17" } tokio = { version = "1", features = [ "rt", "rt-multi-thread", diff --git a/sqllogictest-engines/Cargo.toml b/sqllogictest-engines/Cargo.toml index 43acb3e..0504b2e 100644 --- a/sqllogictest-engines/Cargo.toml +++ b/sqllogictest-engines/Cargo.toml @@ -19,7 +19,7 @@ postgres-types = { version = "0.2.5", features = ["derive", "with-chrono-0_4"] } rust_decimal = { version = "1.30.0", features = ["tokio-pg"] } serde = { version = "1", features = ["derive"] } serde_json = "1" -sqllogictest = { path = "../sqllogictest", version = "0.16" } +sqllogictest = { path = "../sqllogictest", version = "0.17" } thiserror = "1" tokio = { version = "1", features = [ "rt", diff --git a/sqllogictest/Cargo.toml b/sqllogictest/Cargo.toml index f2fdf73..bfb0470 100644 --- a/sqllogictest/Cargo.toml +++ b/sqllogictest/Cargo.toml @@ -11,19 +11,20 @@ description = "Sqllogictest parser and runner." [dependencies] async-trait = "0.1" educe = "0.4.22" -similar = "2.2.1" +fs-err = "2.9.0" +futures = "0.3" glob = "0.3" humantime = "2" itertools = "0.11" -tracing = "0.1" -tempfile = "3" -thiserror = "1" -futures = "0.3" libtest-mimic = "0.6" -regex = "1.9.1" -owo-colors = "3.5.0" md-5 = "0.10" -fs-err = "2.9.0" +owo-colors = "3.5.0" +regex = "1.9.1" +similar = "2.2.1" +subst = "0.3" +tempfile = "3" +thiserror = "1" +tracing = "0.1" [dev-dependencies] pretty_assertions = "1" diff --git a/sqllogictest/src/lib.rs b/sqllogictest/src/lib.rs index ac80309..fa4d6ad 100644 --- a/sqllogictest/src/lib.rs +++ b/sqllogictest/src/lib.rs @@ -36,6 +36,7 @@ pub mod column_type; pub mod connection; +pub mod harness; pub mod parser; pub mod runner; @@ -44,4 +45,4 @@ pub use self::connection::*; pub use self::parser::*; pub use self::runner::*; -pub mod harness; +mod substitution; diff --git a/sqllogictest/src/parser.rs b/sqllogictest/src/parser.rs index 4de1e56..940afdc 100644 --- a/sqllogictest/src/parser.rs +++ b/sqllogictest/src/parser.rs @@ -265,6 +265,7 @@ impl std::fmt::Display for Record { } Record::Control(c) => match c { Control::SortMode(m) => write!(f, "control sortmode {}", m.as_str()), + Control::Substitution(s) => write!(f, "control substitution {}", s.as_str()), }, Record::Condition(cond) => match cond { Condition::OnlyIf { label } => write!(f, "onlyif {label}"), @@ -294,9 +295,38 @@ impl std::fmt::Display for Record { } #[derive(Debug, PartialEq, Eq, Clone)] +#[non_exhaustive] pub enum Control { /// Control sort mode. SortMode(SortMode), + /// Control whether or not to substitute variables in the SQL. + Substitution(bool), +} + +trait ControlItem: Sized { + /// Try to parse from string. + fn try_from_str(s: &str) -> Result; + + /// Convert to string. + fn as_str(&self) -> &'static str; +} + +impl ControlItem for bool { + fn try_from_str(s: &str) -> Result { + match s { + "on" => Ok(true), + "off" => Ok(false), + _ => Err(ParseErrorKind::InvalidControl(s.to_string())), + } + } + + fn as_str(&self) -> &'static str { + if *self { + "on" + } else { + "off" + } + } } #[derive(Debug, PartialEq, Eq, Clone)] @@ -360,8 +390,8 @@ pub enum SortMode { ValueSort, } -impl SortMode { - pub fn try_from_str(s: &str) -> Result { +impl ControlItem for SortMode { + fn try_from_str(s: &str) -> Result { match s { "nosort" => Ok(Self::NoSort), "rowsort" => Ok(Self::RowSort), @@ -370,7 +400,7 @@ impl SortMode { } } - pub fn as_str(&self) -> &'static str { + fn as_str(&self) -> &'static str { match self { Self::NoSort => "nosort", Self::RowSort => "rowsort", @@ -651,6 +681,10 @@ fn parse_inner(loc: &Location, script: &str) -> Result records.push(Record::Control(Control::SortMode(sort_mode))), Err(k) => return Err(k.at(loc)), }, + ["substitution", on_off] => match bool::try_from_str(on_off) { + Ok(on_off) => records.push(Record::Control(Control::Substitution(on_off))), + Err(k) => return Err(k.at(loc)), + }, _ => return Err(ParseErrorKind::InvalidLine(line.into()).at(loc)), }, ["hash-threshold", threshold] => { @@ -758,6 +792,11 @@ mod tests { parse_roundtrip::("../tests/slt/rowsort.slt") } + #[test] + fn test_substitution() { + parse_roundtrip::("../tests/substitution/basic.slt") + } + #[test] fn test_test_dir_escape() { parse_roundtrip::("../tests/test_dir_escape/test_dir_escape.slt") diff --git a/sqllogictest/src/runner.rs b/sqllogictest/src/runner.rs index 6916eaa..67252ec 100644 --- a/sqllogictest/src/runner.rs +++ b/sqllogictest/src/runner.rs @@ -16,11 +16,14 @@ use md5::Digest; use owo_colors::OwoColorize; use regex::Regex; use similar::{Change, ChangeTag, TextDiff}; -use tempfile::{tempdir, TempDir}; use crate::parser::*; +use crate::substitution::Substitution; use crate::{ColumnType, Connections, MakeConnection}; +/// Type-erased error type. +type AnyError = Arc; + #[derive(Debug, Clone)] #[non_exhaustive] pub enum RecordOutput { @@ -28,14 +31,14 @@ pub enum RecordOutput { Query { types: Vec, rows: Vec>, - error: Option>, + error: Option, }, Statement { count: u64, - error: Option>, + error: Option, }, System { - error: Option>, + error: Option, }, } @@ -248,19 +251,16 @@ pub enum TestErrorKind { #[error("{kind} failed: {err}\n[SQL] {sql}")] Fail { sql: String, - err: Arc, + err: AnyError, kind: RecordKind, }, #[error("system command failed: {err}\n[CMD] {command}")] - SystemFail { - command: String, - err: Arc, - }, + SystemFail { command: String, err: AnyError }, // Remember to also update [`TestErrorKindDisplay`] if this message is changed. #[error("{kind} is expected to fail with error:\n\t{expected_err}\nbut got error:\n\t{err}\n[SQL] {sql}")] ErrorMismatch { sql: String, - err: Arc, + err: AnyError, expected_err: String, kind: RecordKind, }, @@ -476,7 +476,7 @@ pub struct Runner { // validator is used for validate if the result of query equals to expected. validator: Validator, column_type_validator: ColumnTypeValidator, - testdir: Option, + substitution: Option, sort_mode: Option, /// 0 means never hashing hash_threshold: usize, @@ -492,7 +492,7 @@ impl> Runner { Runner { validator: default_validator, column_type_validator: default_column_validator, - testdir: None, + substitution: None, sort_mode: None, hash_threshold: 0, labels: HashSet::new(), @@ -505,14 +505,6 @@ impl> Runner { self.labels.insert(label.to_string()); } - /// Replace the pattern `__TEST_DIR__` in SQL with a temporary directory path. - /// - /// This feature is useful in those tests where data will be written to local - /// files, e.g. `COPY`. - pub fn enable_testdir(&mut self) { - self.testdir = Some(tempdir().expect("failed to create testdir")); - } - pub fn with_validator(&mut self, validator: Validator) { self.validator = validator; } @@ -557,7 +549,15 @@ impl> Runner { expected_count: _, loc: _, } => { - let sql = self.replace_keywords(sql); + let sql = match self.may_substitute(sql) { + Ok(sql) => sql, + Err(error) => { + return RecordOutput::Statement { + count: 0, + error: Some(error), + } + } + }; let conn = match self.conn.get(connection).await { Ok(conn) => conn, @@ -595,7 +595,10 @@ impl> Runner { command, loc: _, } => { - let command = self.replace_keywords(command); + let command = match self.may_substitute(command) { + Ok(command) => command, + Err(error) => return RecordOutput::System { error: Some(error) }, + }; if should_skip(&self.labels, "", &conditions) { return RecordOutput::Nothing; @@ -616,7 +619,7 @@ impl> Runner { #[error("process exited unsuccessfully: {0}")] // message from unstable `ExitStatusError` struct SystemError(ExitStatus); - let error: Option> = match result { + let error: Option = match result { Ok(status) if status.success() => None, Ok(status) => Some(Arc::new(SystemError(status))), Err(e) => Some(Arc::new(e)), @@ -639,7 +642,16 @@ impl> Runner { // not handle yet, label: _, } => { - let sql = self.replace_keywords(sql); + let sql = match self.may_substitute(sql) { + Ok(sql) => sql, + Err(error) => { + return RecordOutput::Query { + error: Some(error), + types: vec![], + rows: vec![], + } + } + }; let conn = match self.conn.get(connection).await { Ok(conn) => conn, @@ -705,12 +717,20 @@ impl> Runner { D::sleep(duration).await; RecordOutput::Nothing } - Record::Control(control) => match control { - Control::SortMode(sort_mode) => { - self.sort_mode = Some(sort_mode); - RecordOutput::Nothing + Record::Control(control) => { + match control { + Control::SortMode(sort_mode) => { + self.sort_mode = Some(sort_mode); + } + Control::Substitution(on_off) => match (&mut self.substitution, on_off) { + (s @ None, true) => *s = Some(Substitution::default()), + (s @ Some(_), false) => *s = None, + _ => {} + }, } - }, + + RecordOutput::Nothing + } Record::HashThreshold { loc: _, threshold } => { self.hash_threshold = threshold as usize; RecordOutput::Nothing @@ -1048,12 +1068,13 @@ impl> Runner { block_on(self.run_parallel_async(glob, hosts, conn_builder, jobs)) } - /// Replace all keywords in the SQL. - fn replace_keywords(&self, sql: String) -> String { - if let Some(testdir) = &self.testdir { - sql.replace("__TEST_DIR__", testdir.path().to_str().unwrap()) + /// Substitute the input SQL or command with [`Substitution`], if enabled by `control + /// substitution`. + fn may_substitute(&self, input: String) -> Result { + if let Some(substitution) = &self.substitution { + subst::substitute(&input, substitution).map_err(|e| Arc::new(e) as AnyError) } else { - sql + Ok(input) } } diff --git a/sqllogictest/src/substitution.rs b/sqllogictest/src/substitution.rs new file mode 100644 index 0000000..7ca27da --- /dev/null +++ b/sqllogictest/src/substitution.rs @@ -0,0 +1,29 @@ +use std::sync::OnceLock; + +use subst::Env; +use tempfile::{tempdir, TempDir}; + +/// Substitute environment variables and special variables like `__TEST_DIR__` in SQL. +#[derive(Default)] +pub(crate) struct Substitution { + /// The temporary directory for `__TEST_DIR__`. + /// Lazily initialized and cleaned up when dropped. + test_dir: OnceLock, +} + +impl<'a> subst::VariableMap<'a> for Substitution { + type Value = String; + + fn get(&'a self, key: &str) -> Option { + match key { + "__TEST_DIR__" => { + let test_dir = self + .test_dir + .get_or_init(|| tempdir().expect("failed to create testdir")); + test_dir.path().to_string_lossy().into_owned().into() + } + + key => Env.get(key), + } + } +} diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 3fad772..5b22650 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -6,6 +6,7 @@ publish = false [dependencies] regex = "1.9.1" +rusty-fork = "0.3" sqllogictest = { path = "../sqllogictest" } [[test]] @@ -28,3 +29,7 @@ path = "./test_dir_escape/test_dir_escape.rs" [[test]] name = "system_command" path = "./system_command/system_command.rs" + +[[test]] +name = "substitution" +path = "./substitution/substitution.rs" diff --git a/tests/substitution/basic.slt b/tests/substitution/basic.slt new file mode 100644 index 0000000..bc7d130 --- /dev/null +++ b/tests/substitution/basic.slt @@ -0,0 +1,39 @@ +# by default, substitution is off so we're strictly compatible with other implementations +query T +select $MY_USERNAME +---- +$MY_USERNAME + +# enable substitution with `control` +control substitution on + +# now we can use variables in different forms +query T +select $MY_USERNAME, ${MY_PASSWORD}, ${MY_INEXISTENT_PORT:11451}, ${MY_DATABASE:$MY_USERNAME-db} +---- +sqllogictest, rust, 11451, sqllogictest-db + +# also in statements +statement ok +check $MY_USERNAME + +# also in commands +system ok +echo "$MY_USERNAME" + +# a special variable `__TEST_DIR__` is available with a temporary directory +statement ok +path $__TEST_DIR__ + +# non existent variables without default values are errors +statement error No such variable +check $NONEXISTENT_VARIABLE + +# disable substitution with `control` +control substitution off + +# now we can't use variables +query T +select $MY_USERNAME +---- +$MY_USERNAME diff --git a/tests/substitution/substitution.rs b/tests/substitution/substitution.rs new file mode 100644 index 0000000..8b62d81 --- /dev/null +++ b/tests/substitution/substitution.rs @@ -0,0 +1,61 @@ +use rusty_fork::rusty_fork_test; +use sqllogictest::{DBOutput, DefaultColumnType}; + +pub struct FakeDB; + +#[derive(Debug)] +pub struct FakeDBError; + +impl std::fmt::Display for FakeDBError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{self:?}") + } +} + +impl std::error::Error for FakeDBError {} + +impl sqllogictest::DB for FakeDB { + type Error = FakeDBError; + type ColumnType = DefaultColumnType; + + fn run(&mut self, sql: &str) -> Result, FakeDBError> { + println!("{sql}"); + + let result = match sql.trim().split_once(' ') { + Some(("select", x)) => x.to_string(), + Some(("check", x)) => { + if x.is_empty() { + return Err(FakeDBError); + } else { + x.to_string() + } + } + Some(("path", x)) => { + if std::fs::metadata(x).is_err() { + return Err(FakeDBError); + } else { + x.to_string() + } + } + _ => return Err(FakeDBError), + }; + + Ok(DBOutput::Rows { + types: vec![DefaultColumnType::Text], + rows: vec![vec![result]], + }) + } +} + +// Fork a subprocess to interference with the environment variables. +rusty_fork_test! { + #[test] + fn test_basic() { + std::env::set_var("MY_USERNAME", "sqllogictest"); + std::env::set_var("MY_PASSWORD", "rust"); + + let mut tester = sqllogictest::Runner::new(|| async { Ok(FakeDB) }); + + tester.run_file("./substitution/basic.slt").unwrap(); + } +} diff --git a/tests/system_command/system_command.rs b/tests/system_command/system_command.rs index 5566afa..6d191a3 100644 --- a/tests/system_command/system_command.rs +++ b/tests/system_command/system_command.rs @@ -25,6 +25,8 @@ impl sqllogictest::DB for FakeDB { .ok_or(FakeDBError)? .as_str(); + println!("{path}"); + let content = std::fs::read_to_string(path) .map_err(|_| FakeDBError)? .trim() @@ -40,8 +42,6 @@ impl sqllogictest::DB for FakeDB { #[test] fn test() { let mut tester = sqllogictest::Runner::new(|| async { Ok(FakeDB) }); - // enable `__TEST_DIR__` override - tester.enable_testdir(); tester .run_file("./system_command/system_command.slt") @@ -51,8 +51,6 @@ fn test() { #[test] fn test_fail() { let mut tester = sqllogictest::Runner::new(|| async { Ok(FakeDB) }); - // enable `__TEST_DIR__` override - tester.enable_testdir(); let err = tester .run_file("./system_command/system_command_fail.slt") diff --git a/tests/system_command/system_command.slt b/tests/system_command/system_command.slt index d0f78d9..afd70d9 100644 --- a/tests/system_command/system_command.slt +++ b/tests/system_command/system_command.slt @@ -1,15 +1,17 @@ +control substitution on + system ok -echo 114514 > __TEST_DIR__/test.txt +echo 114514 > ${__TEST_DIR__}/test.txt query T -select read("__TEST_DIR__/test.txt") +select read("${__TEST_DIR__}/test.txt") ---- 114514 system ok -echo 1919810 > __TEST_DIR__/test.txt +echo 1919810 > ${__TEST_DIR__}/test.txt query T -select read("__TEST_DIR__/test.txt") +select read("${__TEST_DIR__}/test.txt") ---- 1919810 diff --git a/tests/system_command/system_command_fail.slt b/tests/system_command/system_command_fail.slt index 2831572..bd42531 100644 --- a/tests/system_command/system_command_fail.slt +++ b/tests/system_command/system_command_fail.slt @@ -1,2 +1,4 @@ +control substitution on + system ok -__TEST_DIR__/something_than_not_exist +${__TEST_DIR__}/something_than_not_exist diff --git a/tests/test_dir_escape/test_dir_escape.rs b/tests/test_dir_escape/test_dir_escape.rs index 44d1acc..c37351b 100644 --- a/tests/test_dir_escape/test_dir_escape.rs +++ b/tests/test_dir_escape/test_dir_escape.rs @@ -28,8 +28,6 @@ impl sqllogictest::DB for FakeDB { #[test] fn test() { let mut tester = sqllogictest::Runner::new(|| async { Ok(FakeDB) }); - // enable `__TEST_DIR__` override - tester.enable_testdir(); tester .run_file("./test_dir_escape/test_dir_escape.slt") diff --git a/tests/test_dir_escape/test_dir_escape.slt b/tests/test_dir_escape/test_dir_escape.slt index e296070..a23f22c 100644 --- a/tests/test_dir_escape/test_dir_escape.slt +++ b/tests/test_dir_escape/test_dir_escape.slt @@ -1,2 +1,4 @@ +control substitution on + statement ok -copy test to '__TEST_DIR__/test.csv'; +copy test to '${__TEST_DIR__}/test.csv';