From 60ddcb007807e457e9f105950a8cb36b0e153f10 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Wed, 8 Nov 2023 17:38:01 +0700 Subject: [PATCH] Run runtime tests as part of cargo test - but ignored for now Signed-off-by: Ryan Levick --- Cargo.lock | 77 +++- Cargo.toml | 3 +- crates/doctor/Cargo.toml | 4 +- test-components/sqlite/README.md | 2 - tests/runtime-tests/Cargo.lock | 435 -------------------- tests/runtime-tests/Cargo.toml | 2 - tests/runtime-tests/src/{main.rs => lib.rs} | 18 +- tests/runtime.rs | 5 + 8 files changed, 82 insertions(+), 464 deletions(-) delete mode 100644 tests/runtime-tests/Cargo.lock rename tests/runtime-tests/src/{main.rs => lib.rs} (96%) create mode 100644 tests/runtime.rs diff --git a/Cargo.lock b/Cargo.lock index 90ae599fc7..20a013c258 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1860,6 +1860,19 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -2694,6 +2707,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "0.14.25" @@ -4998,6 +5017,18 @@ dependencies = [ "winapi", ] +[[package]] +name = "runtime-tests" +version = "0.1.0" +dependencies = [ + "anyhow", + "env_logger", + "log", + "nix 0.26.2", + "temp-dir", + "toml 0.8.8", +] + [[package]] name = "rusqlite" version = "0.29.0" @@ -5350,9 +5381,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" dependencies = [ "serde", ] @@ -5652,6 +5683,7 @@ dependencies = [ "regex", "reqwest", "rpassword", + "runtime-tests", "semver", "serde", "serde_json", @@ -5751,7 +5783,7 @@ dependencies = [ "tempfile", "terminal", "tokio", - "toml 0.8.2", + "toml 0.8.8", "toml_edit 0.20.2", "tracing", "ui-testing", @@ -5771,7 +5803,7 @@ dependencies = [ "spin-app", "spin-locked-app", "spin-testing", - "toml 0.8.2", + "toml 0.8.8", "tracing", "wasmtime-wasi-http", ] @@ -5913,7 +5945,7 @@ dependencies = [ "thiserror", "tokio", "tokio-util 0.6.10", - "toml 0.8.2", + "toml 0.8.8", "tracing", "ui-testing", "walkdir", @@ -5956,7 +5988,7 @@ dependencies = [ "spin-serde", "terminal", "thiserror", - "toml 0.8.2", + "toml 0.8.8", "ui-testing", "url", ] @@ -6440,6 +6472,12 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" +[[package]] +name = "temp-dir" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af547b166dd1ea4b472165569fc456cfb6818116f854690b0ff205e636523dab" + [[package]] name = "tempfile" version = "3.8.0" @@ -6801,15 +6839,15 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.2" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" +checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" dependencies = [ "indexmap 2.0.0", "serde", "serde_spanned", - "toml_datetime 0.6.3", - "toml_edit 0.20.2", + "toml_datetime 0.6.5", + "toml_edit 0.21.0", ] [[package]] @@ -6823,9 +6861,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -6852,7 +6890,20 @@ dependencies = [ "indexmap 2.0.0", "serde", "serde_spanned", - "toml_datetime 0.6.3", + "toml_datetime 0.6.5", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +dependencies = [ + "indexmap 2.0.0", + "serde", + "serde_spanned", + "toml_datetime 0.6.5", "winnow", ] diff --git a/Cargo.toml b/Cargo.toml index baaf7e6214..8d68382ecb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,6 +86,7 @@ hyper = { workspace = true } sha2 = "0.10.1" which = "4.2.5" e2e-testing = { path = "crates/e2e-testing" } +runtime-tests = { path = "tests/runtime-tests" } [build-dependencies] cargo-target-dep = { git = "https://github.com/fermyon/cargo-target-dep", rev = "b7b1989fe0984c0f7c4966398304c6538e52fe49" } @@ -107,7 +108,7 @@ llm-metal = ["llm", "spin-trigger-http/llm-metal"] llm-cublas = ["llm", "spin-trigger-http/llm-cublas"] [workspace] -members = ["crates/*", "sdk/rust", "sdk/rust/macro"] +members = ["crates/*", "sdk/rust", "sdk/rust/macro", "tests/runtime-tests"] [workspace.dependencies] anyhow = "1.0.75" diff --git a/crates/doctor/Cargo.toml b/crates/doctor/Cargo.toml index d2625d3cb4..42007c7883 100644 --- a/crates/doctor/Cargo.toml +++ b/crates/doctor/Cargo.toml @@ -15,7 +15,7 @@ tempfile = "3.3.0" terminal = { path = "../terminal" } tokio = { version = "1", features = ["process"] } toml = "0.8.2" -toml_edit = "0.20.2" +toml_edit = { version = "0.20.2", features = ["serde"] } tracing = { workspace = true } [dev-dependencies] @@ -27,4 +27,4 @@ ui-testing = { path = "../ui-testing" } [[test]] name = "ui" path = "tests/ui.rs" -harness = false \ No newline at end of file +harness = false diff --git a/test-components/sqlite/README.md b/test-components/sqlite/README.md index 5d9ff71116..585c224c00 100644 --- a/test-components/sqlite/README.md +++ b/test-components/sqlite/README.md @@ -6,6 +6,4 @@ Tests the SQLite interface. This test component expects the following to be true: * It is given permission to open a connection to the "default" database. -* That database has one table named `test_data` with two text columns (`key` and `value`) -* `test_data` has at least one row with `key` set to `my_key` and value set to `my_value`. * It does not have permission to access a database named "forbidden". diff --git a/tests/runtime-tests/Cargo.lock b/tests/runtime-tests/Cargo.lock deleted file mode 100644 index d1701ee47a..0000000000 --- a/tests/runtime-tests/Cargo.lock +++ /dev/null @@ -1,435 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - -[[package]] -name = "anyhow" -version = "1.0.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "env_logger" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" -dependencies = [ - "libc", - "windows-sys", -] - -[[package]] -name = "hashbrown" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" - -[[package]] -name = "hermit-abi" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" - -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] -name = "indexmap" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi", - "rustix", - "windows-sys", -] - -[[package]] -name = "libc" -version = "0.2.150" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" - -[[package]] -name = "linux-raw-sys" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" - -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - -[[package]] -name = "memchr" -version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - -[[package]] -name = "nix" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" -dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset", - "pin-utils", -] - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "proc-macro2" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - -[[package]] -name = "runtime-tests" -version = "0.1.0" -dependencies = [ - "anyhow", - "env_logger", - "log", - "nix", - "temp-dir", - "toml", -] - -[[package]] -name = "rustix" -version = "0.38.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" -dependencies = [ - "bitflags 2.4.1", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] - -[[package]] -name = "serde" -version = "1.0.190" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.190" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_spanned" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" -dependencies = [ - "serde", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "temp-dir" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af547b166dd1ea4b472165569fc456cfb6818116f854690b0ff205e636523dab" - -[[package]] -name = "termcolor" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "toml" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ff9e3abce27ee2c9a37f9ad37238c1bdd4e789c84ba37df76aa4d528f5072cc" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "toml_datetime" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.20.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" -dependencies = [ - "indexmap", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - -[[package]] -name = "winnow" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" -dependencies = [ - "memchr", -] diff --git a/tests/runtime-tests/Cargo.toml b/tests/runtime-tests/Cargo.toml index d98f76899e..ca4ecc7115 100644 --- a/tests/runtime-tests/Cargo.toml +++ b/tests/runtime-tests/Cargo.toml @@ -10,5 +10,3 @@ log = "0.4" nix = "0.26.1" toml = "0.8.6" temp-dir = "0.1.11" - -[workspace] diff --git a/tests/runtime-tests/src/main.rs b/tests/runtime-tests/src/lib.rs similarity index 96% rename from tests/runtime-tests/src/main.rs rename to tests/runtime-tests/src/lib.rs index 0cbcfb0220..c1d4b7f058 100644 --- a/tests/runtime-tests/src/main.rs +++ b/tests/runtime-tests/src/lib.rs @@ -6,9 +6,9 @@ use std::{ use anyhow::Context; -fn main() -> anyhow::Result<()> { +pub fn main() -> anyhow::Result<()> { env_logger::init(); - for test in std::fs::read_dir("tests")? { + for test in std::fs::read_dir("tests/runtime-tests/tests")? { let test = test?; if test.file_type()?.is_dir() { log::info!("Testing: {}", test.path().display()); @@ -16,7 +16,7 @@ fn main() -> anyhow::Result<()> { .context("failed to produce a temporary directory to run the test in")?; log::trace!("temporary directory: {}", temp.path().display()); copy_manifest(&test.path(), &temp)?; - let mut spin = Spin::start(&temp.path())?; + let mut spin = Spin::start(temp.path())?; log::debug!("Spin started on port {}.", spin.port()); // TODO: don't bail everything if the http request fails @@ -128,7 +128,7 @@ impl FromStr for Response { .parse::() .context("malformed response does not contain a status code")?; anyhow::ensure!( - &s.as_bytes()[s.len() - 4..] == &b"\r\n\r\n"[..], + s.as_bytes()[s.len() - 4..] == b"\r\n\r\n"[..], r#"malformed response does not end with the expected CRLF"# ); if code == 500 { @@ -170,16 +170,16 @@ fn make_http_request(spin: &mut Spin) -> Result { if let Some(s) = until_headers.find("content-length: ") { if std::str::from_utf8(&until_headers.as_bytes()[s + 16..]) .unwrap() - .starts_with("0") + .starts_with('0') { let response_with_no_body = String::from_utf8(output[..header_end + 4].to_vec()).unwrap(); return Ok(response_with_no_body); } } - if let Some(_) = output[header_end + 4..] + if output[header_end + 4..] .windows(4) - .find(|c| c == b"\r\n\r\n") + .any(|c| c == b"\r\n\r\n") { let response = String::from_utf8(output[..start].to_vec()) .context("spin HTTP response contained non-utf8 bytes")?; @@ -208,7 +208,7 @@ impl Spin { let mut child = std::process::Command::new("spin") .arg("up") .current_dir(dir) - .args(&["--listen", &format!("127.0.0.1:{port}")]) + .args(["--listen", &format!("127.0.0.1:{port}")]) .stdout(std::process::Stdio::piped()) .stderr(std::process::Stdio::piped()) .spawn()?; @@ -276,7 +276,7 @@ fn kill_process(process: &mut std::process::Child) { } fn component_path(name: &str) -> PathBuf { - PathBuf::from("../../test-components/") + PathBuf::from("test-components/") .join(name) .join("component.wasm") } diff --git a/tests/runtime.rs b/tests/runtime.rs new file mode 100644 index 0000000000..1eaca5cc0f --- /dev/null +++ b/tests/runtime.rs @@ -0,0 +1,5 @@ +#[test] +#[ignore = "ignoring until we have greater confidence this can run without false negatives"] +fn perform_runtime_tests() { + runtime_tests::main().unwrap() +}