File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,13 +37,8 @@ pub struct Civilization<'u> {
3737}
3838
3939impl < ' u > Civilization < ' u > {
40- pub async fn shutdown ( self ) {
41- for handle in & self . handles {
42- handle. stop ( false ) . await ;
43- }
44- for thread in & self . threads {
45- thread. abort ( ) ;
46- }
40+ pub async fn shutdown ( mut self ) {
41+ self . stop_servers ( ) . await ;
4742
4843 if let Some ( BrowserWindow :: Chrome ( window) ) = self . window {
4944 window
@@ -55,6 +50,16 @@ impl<'u> Civilization<'u> {
5550}
5651
5752impl < ' u > Civilization < ' u > {
53+ pub async fn stop_servers ( & mut self ) {
54+ for handle in self . handles . drain ( ..) {
55+ handle. stop ( false ) . await ;
56+ }
57+ for thread in self . threads . drain ( ..) {
58+ thread. abort ( ) ;
59+ }
60+ self . purge_port ( ) ;
61+ }
62+
5863 pub fn ensure_port ( & mut self ) -> u16 {
5964 if self . assigned_server_port . is_none ( ) {
6065 self . assigned_server_port = pick_unused_port ( ) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ mod host_dir {
1414 use super :: * ;
1515
1616 async fn host ( dir : & String , civ : & mut Civilization < ' _ > ) -> Result < ( ) , ToolproofStepError > {
17+ civ. stop_servers ( ) . await ;
18+
1719 let mut attempts = 0 ;
1820 let mut running = false ;
1921 while !running && attempts < 5 {
Original file line number Diff line number Diff line change 1+ name : Browser can serve a directory twice in one test
2+
3+ steps :
4+ - step : I have a "my_test.toolproof.yml" file with the content {yaml}
5+ yaml : |-
6+ name: Inner serve twice test
7+
8+ steps:
9+ - I have a "public/index.html" file with the content "<p>First</p>"
10+ - I serve the directory "public"
11+ - In my browser, I load "/"
12+ - step: In my browser, I evaluate {js}
13+ js: |-
14+ toolproof.assert_eq(document.querySelector("p").innerText, "First");
15+ - I have a "public2/index.html" file with the content "<p>Second</p>"
16+ - I serve the directory "public2"
17+ - In my browser, I load "/"
18+ - step: In my browser, I evaluate {js}
19+ js: |-
20+ toolproof.assert_eq(document.querySelector("p").innerText, "Second");
21+ - I run "%toolproof_path% --timeout 60"
22+ - step : " stdout should contain 'Total passing tests: 1'"
23+ - step : " stdout should contain 'Failing tests: 0'"
24+ - step : " stdout should contain 'All tests passed'"
25+ - stderr should be empty
You can’t perform that action at this time.
0 commit comments