@@ -5,53 +5,44 @@ fn main() {
5
5
. nth ( 1 )
6
6
. expect ( "expected first argument to be path to spin binary" )
7
7
. into ( ) ;
8
- let tests_dir = conformance_tests:: download_tests ( ) . unwrap ( ) ;
8
+ conformance_tests:: run_tests ( move |test| run_test ( test, & spin_binary) ) . unwrap ( ) ;
9
+ }
9
10
10
- for test in conformance_tests:: tests ( & tests_dir) . unwrap ( ) {
11
- println ! ( "Running test '{}'" , test. name) ;
12
- let mut services = Vec :: new ( ) ;
13
- for precondition in test. config . preconditions {
14
- match precondition {
15
- conformance_tests:: config:: Precondition :: HttpEcho => {
16
- services. push ( "http-echo" . into ( ) ) ;
17
- }
18
- conformance_tests:: config:: Precondition :: KeyValueStore ( _) => { }
19
- }
20
- }
21
- let env_config = SpinCli :: config (
22
- SpinConfig {
23
- binary_path : spin_binary. clone ( ) ,
24
- spin_up_args : Vec :: new ( ) ,
25
- app_type : testing_framework:: runtimes:: SpinAppType :: Http ,
26
- } ,
27
- test_environment:: services:: ServicesConfig :: new ( services) . unwrap ( ) ,
28
- move |e| {
29
- let mut manifest =
30
- test_environment:: manifest_template:: EnvTemplate :: from_file ( & test. manifest )
31
- . unwrap ( ) ;
32
- manifest. substitute ( e, |_| None ) . unwrap ( ) ;
33
- e. write_file ( "spin.toml" , manifest. contents ( ) ) ?;
34
- e. copy_into ( & test. component , test. component . file_name ( ) . unwrap ( ) ) ?;
35
- Ok ( ( ) )
36
- } ,
37
- ) ;
38
- let mut env = test_environment:: TestEnvironment :: up ( env_config, |_| Ok ( ( ) ) ) . unwrap ( ) ;
39
- for invocation in test. config . invocations {
40
- let conformance_tests:: config:: Invocation :: Http ( mut invocation) = invocation;
41
- invocation. request . substitute_from_env ( & mut env) . unwrap ( ) ;
42
- let spin = env. runtime_mut ( ) ;
43
- let actual = invocation
44
- . request
45
- . send ( |request| spin. make_http_request ( request) )
46
- . unwrap ( ) ;
47
- if let Err ( e) =
48
- conformance_tests:: assertions:: assert_response ( & invocation. response , & actual)
49
- {
50
- eprintln ! ( "Test '{}' failed: {e}" , test. name) ;
51
- eprintln ! ( "stderr: {}" , spin. stderr( ) ) ;
52
- std:: process:: exit ( 1 ) ;
11
+ fn run_test ( test : conformance_tests:: Test , spin_binary : & std:: path:: Path ) -> anyhow:: Result < ( ) > {
12
+ let mut services = Vec :: new ( ) ;
13
+ for precondition in test. config . preconditions {
14
+ match precondition {
15
+ conformance_tests:: config:: Precondition :: HttpEcho => {
16
+ services. push ( "http-echo" . into ( ) ) ;
53
17
}
18
+ conformance_tests:: config:: Precondition :: KeyValueStore ( _) => { }
54
19
}
55
20
}
56
- println ! ( "All tests passed!" )
21
+ let env_config = SpinCli :: config (
22
+ SpinConfig {
23
+ binary_path : spin_binary. to_owned ( ) ,
24
+ spin_up_args : Vec :: new ( ) ,
25
+ app_type : testing_framework:: runtimes:: SpinAppType :: Http ,
26
+ } ,
27
+ test_environment:: services:: ServicesConfig :: new ( services) ?,
28
+ move |e| {
29
+ let mut manifest =
30
+ test_environment:: manifest_template:: EnvTemplate :: from_file ( & test. manifest ) ?;
31
+ manifest. substitute ( e, |_| None ) ?;
32
+ e. write_file ( "spin.toml" , manifest. contents ( ) ) ?;
33
+ e. copy_into ( & test. component , test. component . file_name ( ) . unwrap ( ) ) ?;
34
+ Ok ( ( ) )
35
+ } ,
36
+ ) ;
37
+ let mut env = test_environment:: TestEnvironment :: up ( env_config, |_| Ok ( ( ) ) ) ?;
38
+ for invocation in test. config . invocations {
39
+ let conformance_tests:: config:: Invocation :: Http ( mut invocation) = invocation;
40
+ invocation. request . substitute_from_env ( & mut env) ?;
41
+ let spin = env. runtime_mut ( ) ;
42
+ let actual = invocation
43
+ . request
44
+ . send ( |request| spin. make_http_request ( request) ) ?;
45
+ conformance_tests:: assertions:: assert_response ( & invocation. response , & actual) ?;
46
+ }
47
+ Ok ( ( ) )
57
48
}
0 commit comments