11import { describe , expect , it , x } from "./suite.ts" ;
22import { each , run , type Stream } from "../mod.ts" ;
33
4- function * until ( stream : Stream < string , void > , text : string ) {
4+ function * detect ( stream : Stream < string , void > , text : string ) {
55 for ( const line of yield * each ( stream ) ) {
66 if ( line . includes ( text ) ) {
77 return ;
@@ -15,7 +15,7 @@ describe("main", () => {
1515 await run ( function * ( ) {
1616 let proc = yield * x ( "deno" , [ "run" , "test/main/ok.daemon.ts" ] ) ;
1717
18- yield * until ( proc . lines , "started" ) ;
18+ yield * detect ( proc . lines , "started" ) ;
1919
2020 const { exitCode, stdout } = yield * proc . kill ( "SIGINT" ) ;
2121
@@ -25,34 +25,36 @@ describe("main", () => {
2525 } ) ;
2626 } ) ;
2727
28- it ( "gracefully shuts down on SIGTERM" , async ( ) => {
29- await run ( function * ( ) {
30- let proc = yield * x ( "deno" , [ "run" , "test/main/ok.daemon.ts" ] ) ;
28+ if ( Deno . build . os !== "windows" ) {
29+ it ( "gracefully shuts down on SIGTERM" , async ( ) => {
30+ await run ( function * ( ) {
31+ let proc = yield * x ( "deno" , [ "run" , "test/main/ok.daemon.ts" ] ) ;
3132
32- yield * until ( proc . lines , "started" ) ;
33+ yield * detect ( proc . lines , "started" ) ;
3334
34- const { exitCode, stdout } = yield * proc . kill ( "SIGTERM" ) ;
35+ const { exitCode, stdout } = yield * proc . kill ( "SIGTERM" ) ;
3536
36- expect ( stdout ) . toContain ( "gracefully stopped" ) ;
37+ expect ( stdout ) . toContain ( "gracefully stopped" ) ;
3738
38- expect ( exitCode ) . toBe ( 143 ) ;
39+ expect ( exitCode ) . toBe ( 143 ) ;
40+ } ) ;
3941 } ) ;
40- } ) ;
42+ }
4143
4244 it ( "exits gracefully on explicit exit()" , async ( ) => {
4345 await run ( function * ( ) {
4446 let proc = yield * x ( "deno" , [ "run" , "test/main/ok.exit.ts" ] ) ;
4547
46- yield * until ( proc . lines , "goodbye." ) ;
47- yield * until ( proc . lines , "Ok, computer." ) ;
48+ yield * detect ( proc . lines , "goodbye." ) ;
49+ yield * detect ( proc . lines , "Ok, computer." ) ;
4850 } ) ;
4951 } ) ;
5052
5153 it ( "exits gracefully with 0 on implicit exit" , async ( ) => {
5254 await run ( function * ( ) {
5355 let proc = yield * x ( "deno" , [ "run" , "test/main/ok.implicit.ts" ] ) ;
5456
55- yield * until ( proc . lines , "goodbye." ) ;
57+ yield * detect ( proc . lines , "goodbye." ) ;
5658
5759 const { exitCode } = yield * proc ;
5860
@@ -88,7 +90,7 @@ describe("main", () => {
8890 await run ( function * ( ) {
8991 let proc = yield * x ( "deno" , [ "run" , "test/main/just.suspend.ts" ] ) ;
9092
91- yield * until ( proc . lines , "started" ) ;
93+ yield * detect ( proc . lines , "started" ) ;
9294
9395 const { exitCode, stdout } = yield * proc . kill ( "SIGINT" ) ;
9496
0 commit comments