Skip to content

Commit ace7195

Browse files
rylevkate-goldenring
authored andcommitted
Update to latest tests
Signed-off-by: Ryan Levick <[email protected]>
1 parent f2e1752 commit ace7195

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

conformance-tests/src/main.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,41 @@ fn main() {
2121
.next()
2222
.expect("expected second arg to be path to ctr binary");
2323

24-
for test in conformance_tests::tests(&tests_dir).unwrap() {
24+
'test: for test in conformance_tests::tests(&tests_dir).unwrap() {
25+
println!("running test: {}", test.name);
2526
// Just using TTL.sh until we decide where to host these (local registry, ghcr, etc)
2627
let oci_image = format!("ttl.sh/{}:72h", test.name);
2728
let env_config = SpinShim::config(
2829
ctr_binary.into(),
2930
spin_binary.into(),
3031
oci_image.clone(),
31-
test_environment::services::ServicesConfig::none(),
32+
test_environment::services::ServicesConfig::new(test.config.services).unwrap(),
3233
);
3334
let mut env = TestEnvironment::up(env_config, move |e| {
34-
e.copy_into(&test.manifest, "spin.toml")?;
35+
let mut manifest =
36+
test_environment::manifest_template::EnvTemplate::from_file(&test.manifest)
37+
.unwrap();
38+
manifest.substitute(e, |_| None).unwrap();
39+
e.write_file("spin.toml", manifest.contents())?;
3540
e.copy_into(&test.component, test.component.file_name().unwrap())?;
3641
Ok(())
3742
})
3843
.unwrap();
39-
let shim = env.runtime_mut();
4044
for invocation in test.config.invocations {
41-
let conformance_tests::config::Invocation::Http(invocation) = invocation;
42-
invocation
43-
.run(|request| shim.make_http_request(request))
44-
.unwrap();
45+
let conformance_tests::config::Invocation::Http(mut invocation) = invocation;
46+
invocation.request.substitute_from_env(&mut env).unwrap();
47+
let shim = env.runtime_mut();
48+
if let Err(e) = invocation.run(|request| shim.make_http_request(request)) {
49+
println!("❌ test failed: {}", test.name);
50+
println!("error: {}", e);
51+
for e in e.chain() {
52+
println!("\t{}", e);
53+
}
54+
55+
continue 'test;
56+
}
4557
}
46-
println!("test passed: {}", test.name);
58+
println!("test passed: {}", test.name);
4759
}
4860
}
4961

@@ -181,7 +193,6 @@ impl SpinShim {
181193
if let Some(status) = self.try_wait()? {
182194
anyhow::bail!("Spin exited early with status code {:?}", status.code());
183195
}
184-
println!("Response: {}", response.status());
185196
Ok(response)
186197
}
187198

0 commit comments

Comments
 (0)