File tree Expand file tree Collapse file tree 3 files changed +42
-4
lines changed
Expand file tree Collapse file tree 3 files changed +42
-4
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,44 @@ fn test_new_usage_syntax_execution() {
107107 . stdout ( contains ( "baz: myvalue" ) ) ;
108108}
109109
110+ /// Test that the new // [USAGE] syntax works correctly for non-shell script
111+ #[ test]
112+ fn test_usage_double_slash_execution ( ) {
113+ let mut cmd = Command :: new ( cargo:: cargo_bin!( "usage" ) ) ;
114+ cmd. args ( [
115+ "exec" ,
116+ "node" ,
117+ "../examples/test-usage-double-slash.js" ,
118+ "--debug" ,
119+ "mycmd" ,
120+ ] ) ;
121+
122+ cmd. assert ( )
123+ . success ( )
124+ . stdout ( contains ( "debug: true" ) )
125+ . stdout ( contains ( "port: 3000" ) )
126+ . stdout ( contains ( "command: mycmd" ) ) ;
127+ }
128+
129+ /// Test that the //Usage syntax (no space) works correctly for non-shell script
130+ #[ test]
131+ fn test_usage_double_slash_execution_old ( ) {
132+ let mut cmd = Command :: new ( cargo:: cargo_bin!( "usage" ) ) ;
133+ cmd. args ( [
134+ "exec" ,
135+ "node" ,
136+ "../examples/test-usage-double-slash-old.js" ,
137+ "--debug" ,
138+ "mycmd" ,
139+ ] ) ;
140+
141+ cmd. assert ( )
142+ . success ( )
143+ . stdout ( contains ( "debug: true" ) )
144+ . stdout ( contains ( "port: 3000" ) )
145+ . stdout ( contains ( "command: mycmd" ) ) ;
146+ }
147+
110148/// Test that blank comment lines in USAGE blocks don't stop parsing
111149#[ test]
112150fn test_blank_comment_lines_in_usage ( ) {
Original file line number Diff line number Diff line change 1- #!/usr/bin/env -S usage node
1+ #!/usr/bin/env -S usage exec node
22//
3- // Test script for old USAGE syntax with // comments
3+ // Test non-shell script for old USAGE syntax with // comments
44//
55//USAGE bin "test-double-slash-old"
66//USAGE flag "--debug" help="Debug mode"
Original file line number Diff line number Diff line change 1- #!/usr/bin/env -S usage node
1+ #!/usr/bin/env -S usage exec node
22//
3- // Test script for new USAGE syntax with // comments
3+ // Test non-shell script for new USAGE syntax with // comments
44//
55// [USAGE] bin "test-double-slash"
66// [USAGE] flag "--debug" help="Debug mode"
You can’t perform that action at this time.
0 commit comments