live: cleanup live_test.v output, remove 1s delay
							parent
							
								
									d16485c29e
								
							
						
					
					
						commit
						1754ba19d8
					
				|  | @ -120,11 +120,17 @@ fn testsuite_begin() { | ||||||
| 	atomic_write_source( live_program_source ) | 	atomic_write_source( live_program_source ) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | [if debuglivetest] | ||||||
|  | fn vprintln(s string) { | ||||||
|  | 	eprintln(s) | ||||||
|  | } | ||||||
|  | 
 | ||||||
| fn testsuite_end() { | fn testsuite_end() { | ||||||
| 	eprintln('source: $source_file') | 	vprintln('source: $source_file') | ||||||
| 	eprintln('output: $output_file') | 	vprintln('output: $output_file') | ||||||
| 	println('---------------------------------------------------------------------------') | 	vprintln('---------------------------------------------------------------------------') | ||||||
| 	output_lines := os.read_lines(output_file) or { | 	output_lines := os.read_lines(output_file) or { | ||||||
|  | 		eprintln('could not read $output_file, error: $err') | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	mut histogram := map[string]int | 	mut histogram := map[string]int | ||||||
|  | @ -132,9 +138,9 @@ fn testsuite_end() { | ||||||
| 		histogram[line] = histogram[line] + 1 | 		histogram[line] = histogram[line] + 1 | ||||||
| 	} | 	} | ||||||
| 	for k, v in histogram { | 	for k, v in histogram { | ||||||
| 		println('> found ${v:5d} times: ${k}') | 		eprintln('> found ${v:5d} times: ${k}') | ||||||
| 	} | 	} | ||||||
| 	println('---------------------------------------------------------------------------') | 	vprintln('---------------------------------------------------------------------------') | ||||||
| 	assert histogram['START'] > 0 | 	assert histogram['START'] > 0 | ||||||
| 	assert histogram['ORIGINAL'] > 0 | 	assert histogram['ORIGINAL'] > 0 | ||||||
| 	assert histogram['CHANGED'] + histogram['ANOTHER'] > 0 | 	assert histogram['CHANGED'] + histogram['ANOTHER'] > 0 | ||||||
|  | @ -143,7 +149,7 @@ fn testsuite_end() { | ||||||
| 
 | 
 | ||||||
| fn change_source(new string) { | fn change_source(new string) { | ||||||
| 	time.sleep_ms(100) | 	time.sleep_ms(100) | ||||||
| 	eprintln('> change ORIGINAL to: $new') | 	vprintln('> change ORIGINAL to: $new') | ||||||
| 	atomic_write_source( live_program_source.replace('ORIGINAL', new) ) | 	atomic_write_source( live_program_source.replace('ORIGINAL', new) ) | ||||||
| 	wait_for_file(new) | 	wait_for_file(new) | ||||||
| }     | }     | ||||||
|  | @ -151,13 +157,14 @@ fn change_source(new string) { | ||||||
| fn wait_for_file(new string){ | fn wait_for_file(new string){ | ||||||
| 	time.sleep_ms(100) | 	time.sleep_ms(100) | ||||||
| 	expected_file := os.join_path(os.temp_dir(), new + '.txt') | 	expected_file := os.join_path(os.temp_dir(), new + '.txt') | ||||||
|  | 	eprintln('waiting for $expected_file ...') | ||||||
| 	for i:=0 ; i <= 400 ; i++ { | 	for i:=0 ; i <= 400 ; i++ { | ||||||
| 		if i % 25 == 0 { | 		if i % 25 == 0 { | ||||||
| 			eprintln('   checking ${i:-10d} for $expected_file ...') | 			vprintln('   checking ${i:-10d} for $expected_file ...') | ||||||
| 		} | 		} | ||||||
| 		if os.exists( expected_file ) { | 		if os.exists( expected_file ) { | ||||||
| 			assert true | 			assert true | ||||||
| 			eprintln('> done.') | 			vprintln('> done.') | ||||||
| 			time.sleep_ms(100) | 			time.sleep_ms(100) | ||||||
| 			break | 			break | ||||||
| 		} | 		} | ||||||
|  | @ -174,7 +181,6 @@ fn test_live_program_can_be_compiled() { | ||||||
| 	eprintln('Running with: $cmd') | 	eprintln('Running with: $cmd') | ||||||
| 	res := os.system(cmd) | 	res := os.system(cmd) | ||||||
| 	assert res == 0 | 	assert res == 0 | ||||||
| 	time.sleep_ms(1000) |  | ||||||
| 	eprintln('... running in the background') | 	eprintln('... running in the background') | ||||||
| 	wait_for_file('ORIGINAL') | 	wait_for_file('ORIGINAL') | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue