my127 / workspace

Development environment tooling
MIT License
16 stars 13 forks source link

Fixes #144 - Exit code and output stream changes #145

Closed g-foster2020 closed 1 year ago

g-foster2020 commented 1 year ago

Tests

1. ws alone shall be exit 0 and stdout

2a. ws --help shall be exit 0 and stdout

2b. ws -h shall be exit 0 and stdout

3a. ws --help command shall be exit 0 and stdout

3b. ws -h command shall be exit 0 and stdout

4a. ws --help badcommand shall be exit 127 and stderr

4b. ws -h badcommand shall be exit 127 and stderr

5a. ws --help shall not throw an error (command "" does not exist)

5b. ws -h shall not throw an error (command "" does not exist)

6. ws badcommand shall be exit 127 and stderr

fixes #144

andytson-inviqa commented 1 year ago

nice way to test it with that sed stuff :)

g-foster2020 commented 1 year ago

Tests

1. ws alone shall be exit 0 and stdout

❯ bin/workspace 2> >(sed 's/^/2: /') > >(sed 's/^/1: /') 
1: ws
1:
1: Sub Commands:
1:    self-update      Updates the current version of workspace.
1:    version
1:    global
1:    poweroff         Completely disable workspace by shutting down all containers
1:    create
1:    secret
1:    config
1: Global Options:
1:   -h, --help       Show help message
1:   -v, --verbose    Increase verbosity
1:

❯ echo $? 
0

2a. ws --help shall be exit 0 and stdout

❯ bin/workspace --help 2> >(sed 's/^/2: /') > >(sed 's/^/1: /') 
1: ws
1:
1: Sub Commands:
1:    self-update      Updates the current version of workspace.
1:    version
1:    global
1:    poweroff         Completely disable workspace by shutting down all containers
1:    create
1:    secret
1:    config
1: Global Options:
1:   -h, --help       Show help message
1:   -v, --verbose    Increase verbosity
1:

❯ echo $? 
0

2b. ws -h shall be exit 0 and stdout

❯ bin/workspace -h 2> >(sed 's/^/2: /') > >(sed 's/^/1: /') 
1: ws
1:
1: Sub Commands:
1:    self-update      Updates the current version of workspace.
1:    version
1:    global
1:    poweroff         Completely disable workspace by shutting down all containers
1:    create
1:    secret
1:    config
1: Global Options:
1:   -h, --help       Show help message
1:   -v, --verbose    Increase verbosity
1:

❯ echo $? 
0

3a. ws --help command shall be exit 0 and stdout

❯ bin/workspace --help version 2> >(sed 's/^/2: /') > >(sed 's/^/1: /') 
1: ws version
1:
1: Usage:
1:   ws version [options]
1:
1: Global Options:
1:   -h, --help       Show help message
1:   -v, --verbose    Increase verbosity
1:

❯ echo $? 
0

3b. ws -h command shall be exit 0 and stdout

❯ bin/workspace -h version 2> >(sed 's/^/2: /') > >(sed 's/^/1: /') 
1: ws version
1:
1: Usage:
1:   ws version [options]
1:
1: Global Options:
1:   -h, --help       Show help message
1:   -v, --verbose    Increase verbosity
1:

❯ echo $? 
0

4a. ws --help badcommand shall be exit 127 and stderr

❯ bin/workspace --help badcommand 2> >(sed 's/^/2: /') > >(sed 's/^/1: /')  
2:
2:  [ERROR] Command "badcommand" not recognised
2:
1: ws
1:
1: Sub Commands:
1:    self-update      Updates the current version of workspace.
1:    version
1:    global
1:    poweroff         Completely disable workspace by shutting down all containers
1:    create
1:    secret
1:    config
1: Global Options:
1:   -h, --help       Show help message
1:   -v, --verbose    Increase verbosity
1:

❯ echo $? 
127

4b. ws -h badcommand shall be exit 127 and stderr

❯ bin/workspace -h badcommand 2> >(sed 's/^/2: /') > >(sed 's/^/1: /')
2:
2:  [ERROR] Command "badcommand" not recognised
2:
1: ws
1:
1: Sub Commands:
1:    self-update      Updates the current version of workspace.
1:    version
1:    global
1:    poweroff         Completely disable workspace by shutting down all containers
1:    create
1:    secret
1:    config
1: Global Options:
1:   -h, --help       Show help message
1:   -v, --verbose    Increase verbosity
1:

❯ echo $?  
127

5a. ws --help shall not throw an error (command "" does not exist)

❯ bin/workspace --help    
ws

Sub Commands:
   self-update      Updates the current version of workspace.
   version
   global
   poweroff         Completely disable workspace by shutting down all containers
   create
   secret
   config
Global Options:
  -h, --help       Show help message
  -v, --verbose    Increase verbosity

5b. ws -h shall not throw an error (command "" does not exist)

❯ bin/workspace -h 
ws

Sub Commands:
   self-update      Updates the current version of workspace.
   version
   global
   poweroff         Completely disable workspace by shutting down all containers
   create
   secret
   config
Global Options:
  -h, --help       Show help message
  -v, --verbose    Increase verbosity

6. ws badcommand shall be exit 127 and stderr

❯ bin/workspace badcommand 2> >(sed 's/^/2: /') > >(sed 's/^/1: /')  
2:
2:  [ERROR] Command "badcommand" not recognised
2:
1: ws
1:
1: Sub Commands:
1:    self-update      Updates the current version of workspace.
1:    version
1:    global
1:    poweroff         Completely disable workspace by shutting down all containers
1:    create
1:    secret
1:    config
1: Global Options:
1:   -h, --help       Show help message
1:   -v, --verbose    Increase verbosity
1:

❯ echo $?     
127
andytson-inviqa commented 1 year ago
  1. ws badcommand shall be exit 127 and stderr

I was meaning the usage too, since not a function output. However I can accept that's a new feature, just what I was asking for for the exit code ticket so wanted it in 0.3

dantleech commented 1 year ago

it should be fairly trivial to add e2e tests for the exit codes

dantleech commented 1 year ago

the existing exit code tests are here:

https://github.com/my127/workspace/blob/86a6c7cc57054bf1b702c3c57078f1305c480ea3/tests/Test/Application/ApplicationTest.php#L10-L16

g-foster2020 commented 1 year ago

the existing exit code tests are here:

https://github.com/my127/workspace/blob/86a6c7cc57054bf1b702c3c57078f1305c480ea3/tests/Test/Application/ApplicationTest.php#L10-L16

Perfect I will do that.

g-foster2020 commented 1 year ago

@dantleech Added tests.