github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/fixtures/bugs/1558/exercise-1473.sh (about) 1 #! /bin/bash 2 fixturePath="./gen-fixture-1558-flatten/cmd/nrcodegen-server" 3 cmd="${fixturePath}/nrcodegen-server" 4 # Generates a fresh server 5 ./gen-fixtures.sh 6 # Apply wrong options like in #1473 7 patch gen-fixture-1558-flatten/restapi/configure_nrcodegen.go patch-1473-1.patch 8 # 9 (cd ${fixturePath} ; go build) 10 if [[ ! $? -eq 0 ]] ; then 11 echo "Error building server" 12 exit 1 13 fi 14 captured="./srv.log" 15 # This should panic and not hang 16 $cmd --help 1>${captured} 2>&1 17 grep -qi "panic: provided data is not a pointer to struct" ${captured} 18 if [[ $? -eq 0 ]] ; then 19 echo "Server startup panicked as expected. OK" 20 else 21 echo "Server startup did not panick as expected. Wrong. Here is the output:" 22 echo ">>>" 23 cat ${captured} 24 echo ">>>" 25 fi 26 27 # Apply patch to correct this 28 echo "Now fixing the issue..." 29 patch gen-fixture-1558-flatten/restapi/configure_nrcodegen.go patch-1473-2.patch 30 (cd ${fixturePath} ; go build) 31 # This should be ok now 32 echo "Try again..." 33 $cmd --help 1>${captured} 2>&1 34 grep -qi "example1" ${captured} 35 if [[ $? -eq 0 ]] ; then 36 echo "Server startup shows help with additional option. OK" 37 else 38 echo "Server startup did not work as expected. Wrong. Here is the output:" 39 echo ">>>" 40 cat ${captured} 41 echo ">>>" 42 fi