@@ -5,23 +5,28 @@ use std::path::Path;
55
66use crate :: test:: * ;
77use anyhow:: { Context , Result } ;
8- use sh_inline:: { bash , bash_command} ;
8+ use sh_inline:: bash_command;
99use with_procspawn_tempdir:: with_procspawn_tempdir;
10+ use xshell:: cmd;
1011
1112pub ( crate ) fn itest_basic ( ) -> Result < ( ) > {
12- bash ! ( r"ostree --help >/dev/null" ) ?;
13+ let sh = xshell:: Shell :: new ( ) ?;
14+ cmd ! ( sh, "ostree --help >/dev/null" ) . run ( ) ?;
1315 Ok ( ( ) )
1416}
1517
1618#[ with_procspawn_tempdir]
1719pub ( crate ) fn itest_nofifo ( ) -> Result < ( ) > {
20+ let sh = xshell:: Shell :: new ( ) ?;
1821 assert ! ( std:: path:: Path :: new( ".procspawn-tmpdir" ) . exists( ) ) ;
19- bash ! (
20- r"ostree --repo=repo init --mode=archive
22+ cmd ! (
23+ sh,
24+ "ostree --repo=repo init --mode=archive
2125 mkdir tmproot
2226 mkfifo tmproot/afile
2327"
24- ) ?;
28+ )
29+ . run ( ) ?;
2530 cmd_fails_with (
2631 bash_command ! (
2732 r#"ostree --repo=repo commit -b fifotest -s "commit fifo" --tree=dir=./tmproot"#
@@ -34,60 +39,73 @@ pub(crate) fn itest_nofifo() -> Result<()> {
3439
3540#[ with_procspawn_tempdir]
3641pub ( crate ) fn itest_mtime ( ) -> Result < ( ) > {
37- bash ! (
38- r"ostree --repo=repo init --mode=archive
42+ let sh = xshell:: Shell :: new ( ) ?;
43+ cmd ! (
44+ sh,
45+ "ostree --repo=repo init --mode=archive
3946 mkdir tmproot
4047 echo afile > tmproot/afile
4148 ostree --repo=repo commit -b test --tree=dir=tmproot >/dev/null
4249"
43- ) ?;
50+ )
51+ . run ( ) ?;
4452 let ts = Path :: new ( "repo" ) . metadata ( ) ?. modified ( ) . unwrap ( ) ;
4553 std:: thread:: sleep ( std:: time:: Duration :: from_secs ( 1 ) ) ;
46- bash ! ( r#"ostree --repo=repo commit -b test -s "bump mtime" --tree=dir=tmproot >/dev/null"# ) ?;
54+ cmd ! (
55+ sh,
56+ "ostree --repo=repo commit -b test -s 'bump mtime' --tree=dir=tmproot >/dev/null"
57+ )
58+ . run ( ) ?;
4759 assert_ne ! ( ts, Path :: new( "repo" ) . metadata( ) ?. modified( ) . unwrap( ) ) ;
4860 Ok ( ( ) )
4961}
5062
5163#[ with_procspawn_tempdir]
5264pub ( crate ) fn itest_extensions ( ) -> Result < ( ) > {
53- bash ! ( r"ostree --repo=repo init --mode=bare" ) ?;
65+ let sh = xshell:: Shell :: new ( ) ?;
66+ cmd ! ( sh, "ostree --repo=repo init --mode=bare" ) . run ( ) ?;
5467 assert ! ( Path :: new( "repo/extensions" ) . exists( ) ) ;
5568 Ok ( ( ) )
5669}
5770
5871#[ with_procspawn_tempdir]
5972pub ( crate ) fn itest_pull_basicauth ( ) -> Result < ( ) > {
73+ let sh = xshell:: Shell :: new ( ) ?;
6074 let opts = TestHttpServerOpts {
6175 basicauth : true ,
6276 ..Default :: default ( )
6377 } ;
6478 let serverrepo = Path :: new ( "server/repo" ) ;
6579 std:: fs:: create_dir_all ( & serverrepo) ?;
6680 with_webserver_in ( & serverrepo, & opts, move |addr| {
67- let baseuri = http:: Uri :: from_maybe_shared ( format ! ( "http://{}/" , addr) . into_bytes ( ) ) ?;
81+ let baseuri =
82+ http:: Uri :: from_maybe_shared ( format ! ( "http://{}/" , addr) . into_bytes ( ) ) ?. to_string ( ) ;
6883 let unauthuri =
69- http:: Uri :: from_maybe_shared ( format ! ( "http://unknown:badpw@{}/" , addr) . into_bytes ( ) ) ?;
84+ http:: Uri :: from_maybe_shared ( format ! ( "http://unknown:badpw@{}/" , addr) . into_bytes ( ) ) ?
85+ . to_string ( ) ;
7086 let authuri = http:: Uri :: from_maybe_shared (
7187 format ! ( "http://{}@{}/" , TEST_HTTP_BASIC_AUTH , addr) . into_bytes ( ) ,
72- ) ?;
88+ ) ?
89+ . to_string ( ) ;
7390 let osroot = Path :: new ( "osroot" ) ;
7491 crate :: treegen:: mkroot ( & osroot) ?;
75- bash ! (
76- r#"ostree --repo=${serverrepo} init --mode=archive
77- ostree --repo=${serverrepo} commit -b os --tree=dir=${osroot} >/dev/null
78- mkdir client
79- cd client
80- ostree --repo=repo init --mode=archive
81- ostree --repo=repo remote add --set=gpg-verify=false origin-unauth ${baseuri}
82- ostree --repo=repo remote add --set=gpg-verify=false origin-badauth ${unauthuri}
83- ostree --repo=repo remote add --set=gpg-verify=false origin-goodauth ${authuri}
84- "# ,
85- osroot = osroot,
86- serverrepo = serverrepo,
87- baseuri = baseuri. to_string( ) ,
88- unauthuri = unauthuri. to_string( ) ,
89- authuri = authuri. to_string( )
90- ) ?;
92+
93+ cmd ! ( sh, "ostree --repo=${serverrepo} init --mode=archive" ) . run ( ) ?;
94+ cmd ! (
95+ sh,
96+ "ostree --repo=${serverrepo} commit -b os --tree=dir=${osroot} >/dev/null"
97+ )
98+ . run ( ) ?;
99+ cmd ! ( sh, "mkdir client" ) . run ( ) ?;
100+ cmd ! ( sh, "ostree --repo=client/repo init --mode=archive" ) . run ( ) ?;
101+ cmd ! (
102+ sh,
103+ "ostree --repo=client/repo remote add --set=gpg-verify=false origin-unauth ${baseuri}"
104+ )
105+ . run ( ) ?;
106+ cmd ! ( sh, "ostree --repo=client/repo remote add --set=gpg-verify=false origin-badauth ${unauthuri}" ) . run ( ) ?;
107+ cmd ! ( sh, "ostree --repo=client/repo remote add --set=gpg-verify=false origin-goodauth ${authuri}" ) . run ( ) ?;
108+
91109 for rem in & [ "unauth" , "badauth" ] {
92110 cmd_fails_with (
93111 bash_command ! (
@@ -99,7 +117,11 @@ pub(crate) fn itest_pull_basicauth() -> Result<()> {
99117 )
100118 . context ( rem) ?;
101119 }
102- bash ! ( r#"ostree --repo=client/repo pull origin-goodauth os >/dev/null"# , ) ?;
120+ cmd ! (
121+ sh,
122+ "ostree --repo=client/repo pull origin-goodauth os >/dev/null"
123+ )
124+ . run ( ) ?;
103125 Ok ( ( ) )
104126 } ) ?;
105127 Ok ( ( ) )
0 commit comments