File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44//! Sandbox image suite: a sandbox runs the image it is created from.
55
6- use testkit:: { Context , Sandbox } ;
6+ use testkit:: { Context , ResultExt as _ , Sandbox } ;
77
88/// A sandbox created with an explicit image runs that image.
99#[ testkit:: test]
@@ -17,7 +17,7 @@ async fn explicit_image_is_used(cx: &mut Context) -> testkit::Result {
1717 . await ?;
1818 expect_ubuntu ( & sandbox)
1919 . await
20- . map_err ( |error| error . context ( format ! ( "sandbox from image {image}" ) ) )
20+ . context ( format ! ( "sandbox from image {image}" ) )
2121}
2222
2323/// Fail unless the sandbox's `/etc/os-release` names Ubuntu and a version,
Original file line number Diff line number Diff line change @@ -492,6 +492,10 @@ const EPHEMERAL_CLEANUP_TIMEOUT: Duration = Duration::from_secs(60);
492492
493493/// A detached sandbox created with `--no-keep` is removed once its main
494494/// command exits, whether the command succeeds or fails.
495+ ///
496+ /// This checks only what the gateway shows: get and list stop returning the
497+ /// sandbox. It doesn't check that the driver removed its containers, pods or
498+ /// VM state; conformance can't see driver resources.
495499#[ testkit:: test]
496500async fn detached_no_keep_sandbox_is_removed_after_main_exits ( cx : & mut Context ) -> testkit:: Result {
497501 let mut sandboxes = Vec :: new ( ) ;
Original file line number Diff line number Diff line change @@ -137,6 +137,10 @@ async fn expect_sandbox_setting(
137137 . await
138138}
139139
140+ // The global-setting helpers take `&Cli` rather than `&Context` because the
141+ // cleanup hook that restores the setting calls them after the test body,
142+ // when the context can no longer be borrowed.
143+
140144/// The gateway-global value of `key` as the CLI shows it, [`UNSET`] if none.
141145async fn read_global_setting ( cli : & testkit:: Cli , key : & str ) -> testkit:: Result < String > {
142146 let settings: Value = cli
Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ async fn sandbox_from_template_uses_its_workload(cx: &mut Context) -> testkit::R
106106 "template list does not include {template_name}"
107107 ) ;
108108
109+ // `SandboxBuilder` can't create from a template, so name, track and adopt by hand.
109110 let sandbox_name = cx. name ( "ts" ) ;
110111 cx. track ( & sandbox_name) ;
111112 cx. client ( )
Original file line number Diff line number Diff line change @@ -314,6 +314,8 @@ impl SandboxBuilder {
314314 self
315315 }
316316
317+ /// Whether the sandbox restarts when its main command exits: never, on
318+ /// failure, or always.
317319 pub fn restart_policy ( mut self , policy : SandboxRestartPolicy ) -> Self {
318320 self . spec . restart_policy = policy;
319321 self
Original file line number Diff line number Diff line change @@ -31,13 +31,13 @@ impl Error {
3131 self . code
3232 }
3333
34- pub fn from_display ( error : impl fmt:: Display ) -> Self {
34+ pub ( crate ) fn from_display ( error : impl fmt:: Display ) -> Self {
3535 Self :: msg ( error. to_string ( ) )
3636 }
3737
3838 /// An error with its sources, so a wrapper such as tonic's
3939 /// "transport error" still says what went wrong underneath.
40- pub fn from_error ( error : & ( dyn std:: error:: Error + ' static ) ) -> Self {
40+ pub ( crate ) fn from_error ( error : & ( dyn std:: error:: Error + ' static ) ) -> Self {
4141 let mut message = error. to_string ( ) ;
4242 let mut source = error. source ( ) ;
4343 while let Some ( cause) = source {
Original file line number Diff line number Diff line change @@ -231,9 +231,7 @@ fn env(name: &str) -> Option<String> {
231231}
232232
233233fn read ( path : & Path ) -> Result < Vec < u8 > > {
234- std:: fs:: read ( path)
235- . map_err ( Error :: from_display)
236- . context ( format ! ( "read {}" , path. display( ) ) )
234+ std:: fs:: read ( path) . context ( format ! ( "read {}" , path. display( ) ) )
237235}
238236
239237#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments