@@ -15,31 +15,42 @@ expect_error name [code]:
1515
1616expect_file_not_found cmd [code ]:
1717 if ( cmd .index_of " " ) == -1 :
18- expect_error "Error trying to run '$ cmd ' using \$ PATH: No such file or directory" code
18+ if platform == PLATFORM_WINDOWS :
19+ expect_error "Error trying to run '$ cmd ' using \$ PATH: FILE_NOT_FOUND" code
20+ else:
21+ expect_error "Error trying to run '$ cmd ' using \$ PATH: No such file or directory" code
1922 else:
20- expect_error "Error trying to run executable with a space in the filename: '$ cmd ': No such file or directory" code
23+ if platform == PLATFORM_WINDOWS :
24+ expect_error "Error trying to run executable with a space in the filename: '$ cmd ': FILE_NOT_FOUND" code
25+ else:
26+ expect_error "Error trying to run executable with a space in the filename: '$ cmd ': No such file or directory" code
27+
28+ if_windows windows unix :
29+ if platform == PLATFORM_WINDOWS : return windows
30+ return unix
2131
2232main :
2333 // This test does not work on ESP32 since you can't launch subprocesses.
24- if platform == "FreeRTOS" : return
34+ if platform == PLATFORM_FREERTOS : return
2535
2636 print " ** Some child processes will print errors on stderr during **"
2737 print " ** this test. This is harmless and expected. **"
28-
2938 pipe_large_file
3039 write_closed_stdin_exception
3140
3241 expect_equals
3342 0
3443 pipe .system "true"
3544
45+ simple_ls_command := if_windows "dir %ComSpec%" "ls /bin/sh"
3646 expect_equals
3747 0
38- pipe .system "ls /bin/sh"
48+ pipe .system
49+ simple_ls_command
3950
4051 // run_program does not parse the command line, splitting at spaces, so it's
4152 // looking for a single program of the name "ls /bin/sh".
42- expect_file_not_found "ls /bin/sh" : pipe .run_program "ls /bin/sh"
53+ expect_file_not_found simple_ls_command : pipe .run_program simple_ls_command
4354
4455 // There's no such program as ll.
4556 expect_file_not_found "ll" : pipe .run_program "ll" "/bin/sh"
6879 expect_file_not_found no_exist_cmd : pipe .to no_exist_cmd
6980
7081 tmpdir := mkdtemp "/tmp/toit_file_test_"
82+ old_current_directory := cwd
7183
7284 try:
7385 chdir tmpdir
@@ -88,12 +100,19 @@ main:
88100 chdir dirname
89101 go_up = true
90102
91- p = pipe .from "shasum" filename
92103 output := ""
93- while byte_array := p .read :
94- output += byte_array .to_string
104+ if platform == PLATFORM_WINDOWS :
105+ p = pipe .from "certutil" "-hashfile" filename
106+ while byte_array := p .read :
107+ output += byte_array .to_string
108+
109+ expect output == "SHA1 hash of $ filename :\r\n 2dcc8e172c72f3d6937d49be7cf281067d257a62\r\n CertUtil: -hashfile command completed successfully.\r\n "
110+ else:
111+ p = pipe .from "shasum" filename
112+ while byte_array := p .read :
113+ output += byte_array .to_string
95114
96- expect output == "2dcc8e172c72f3d6937d49be7cf281067d257a62 $ filename\n "
115+ expect output == "2dcc8e172c72f3d6937d49be7cf281067d257a62 $ filename\n "
97116
98117 chdir ".."
99118 go_up = false
@@ -107,15 +126,26 @@ main:
107126 finally:
108127 rmdir --recursive tmpdir
109128
110- expect_error "shasum: exited with status 1" :
111- p := pipe .from "shasum" "file_that_doesn't exist"
112- while p .read :
113- // nothing
129+ chdir old_current_directory
130+
131+ if platform == PLATFORM_WINDOWS :
132+ expect_error "certutil: exited with status 2" :
133+ p := pipe .from "certutil" "file_that_doesn't exist"
134+ while p .read :
135+ // Do nothing.
136+
137+ expect_error "certutil: exited with status 2" :
138+ sum := pipe .backticks "certutil" "file_that_doesn't exist"
139+ else:
140+ expect_error "shasum: exited with status 1" :
141+ p := pipe .from "shasum" "file_that_doesn't exist"
142+ while p .read :
143+ // Do nothing.
114144
115- expect_error "shasum: exited with status 1" :
116- sum := pipe .backticks "shasum" "file_that_doesn't exist"
145+ expect_error "shasum: exited with status 1" :
146+ sum := pipe .backticks "shasum" "file_that_doesn't exist"
117147
118- tar_exit_code := ( platform == "Linux" ) ? 2 : 1
148+ tar_exit_code := ( platform == PLATFORM_LINUX ) ? 2 : 1
119149 expect_error "tar: exited with status $ tar_exit_code " :
120150 p := pipe .to "tar" "-xvf" "-" "foo.txt"
121151 p .close // Close without sending a valid tar file.
0 commit comments