1- use std:: path:: Path ;
1+ use std:: { path:: Path , env :: current_dir } ;
22
33use assert_fs:: prelude:: * ;
44
4545
4646fn test_cli_case1 ( ) -> anyhow:: Result < ( ) > {
4747 let temp = assert_fs:: TempDir :: new ( ) ?;
48+ let pre_path = current_dir ( ) ?;
4849 std:: env:: set_current_dir ( temp. path ( ) ) ?;
4950 exec ! ( "git" , "init" ) ?;
5051
@@ -119,12 +120,14 @@ fn test_cli_case1() -> anyhow::Result<()> {
119120 "should still work if I run it again"
120121 ) ;
121122
123+ std:: env:: set_current_dir ( pre_path) ?;
122124 temp. close ( ) ?;
123125 Ok ( ( ) )
124126}
125127
126128fn test_cli_case2 ( ) -> anyhow:: Result < ( ) > {
127129 let temp = assert_fs:: TempDir :: new ( ) ?;
130+ let pre_path = current_dir ( ) ?;
128131 std:: env:: set_current_dir ( temp. path ( ) ) ?;
129132 exec ! ( "git" , "init" ) ?;
130133
@@ -255,12 +258,14 @@ fn test_cli_case2() -> anyhow::Result<()> {
255258 "should skip unstable tags"
256259 ) ;
257260
261+ std:: env:: set_current_dir ( pre_path) ?;
258262 temp. close ( ) ?;
259263 Ok ( ( ) )
260264}
261265
262266fn test_cli_case3 ( ) -> anyhow:: Result < ( ) > {
263267 let temp = assert_fs:: TempDir :: new ( ) ?;
268+ let pre_path = current_dir ( ) ?;
264269 std:: env:: set_current_dir ( temp. path ( ) ) ?;
265270
266271 let binding = temp. join ( "footer" ) ;
@@ -282,16 +287,15 @@ fn test_cli_case3() -> anyhow::Result<()> {
282287 "git semver tags on different cwd"
283288 ) ;
284289
290+ std:: env:: set_current_dir ( pre_path) ?;
285291 temp. close ( ) ?;
286292 Ok ( ( ) )
287293}
288294
289295#[ test]
290296fn test_cli ( ) -> anyhow:: Result < ( ) > {
291297 test_cli_case1 ( ) ?;
292- std:: thread:: sleep ( std:: time:: Duration :: from_secs ( 1 ) ) ;
293298 test_cli_case2 ( ) ?;
294- std:: thread:: sleep ( std:: time:: Duration :: from_secs ( 1 ) ) ;
295299 test_cli_case3 ( ) ?;
296300 Ok ( ( ) )
297301}
0 commit comments