forked from loafle/openapi-generator-original
Add test case to detect stack overflow error (#904)
* add test case to detect stackoverflow errors * use bash insted of sh
This commit is contained in:
parent
1ea0a1e856
commit
5cd5143b80
33
bin/tests/run-all-test
Executable file
33
bin/tests/run-all-test
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# this bash script will loop through all the .sh files under bin/tests
|
||||||
|
# execute the script and check the result (exit code) to see if
|
||||||
|
# there's any error
|
||||||
|
|
||||||
|
echo "IMPORTANT: this script should be run by the CI (e.g. Shippable) only. There's no need to run this script manually."
|
||||||
|
echo "Please press CTRL+C to stop or the script will continue in 10 seconds."
|
||||||
|
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
successes=0
|
||||||
|
failures=0
|
||||||
|
for SCRIPT in $(ls -l ./bin/tests/*.sh | grep -v all)
|
||||||
|
do
|
||||||
|
if [ -f ${SCRIPT} -a -x ${SCRIPT} ]; then
|
||||||
|
echo "Running $SCRIPT (output to /dev/null)"
|
||||||
|
${SCRIPT} 2>&1 > /dev/null
|
||||||
|
rc=$?
|
||||||
|
if [[ ${rc} != 0 ]]; then
|
||||||
|
>&2 echo "ERROR!! FAILED TO RUN ${SCRIPT}"
|
||||||
|
((failures+=1))
|
||||||
|
else
|
||||||
|
((successes+=1))
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if (( failures > 0 )); then
|
||||||
|
>&2 echo "[ERROR] ${failures} out of $((failures+successes)) scripts failed."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "[SUCCESS] ${successes} generators finished."
|
||||||
|
fi
|
38
bin/tests/test-debug-supporting-files.sh
Executable file
38
bin/tests/test-debug-supporting-files.sh
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
echo "# START SCRIPT: $SCRIPT"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn -B clean package $@
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="generate -t modules/openapi-generator/src/main/resources/python -i modules/openapi-generator/src/test/resources/3_0/issue_241.yaml -g python -o /tmp/test-debug-supporting-files/ -DpackageName=petstore_api -DdebugSupportingFiles=true $@"
|
||||||
|
|
||||||
|
if [[ $(java $JAVA_OPTS -jar $executable $ags 2>&1 | grep "StackOverflowError") ]]; then
|
||||||
|
echo "There are StackOverflowError. Please check the result."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "No StackOverflowError found."
|
||||||
|
fi
|
||||||
|
|
@ -0,0 +1,47 @@
|
|||||||
|
openapi: "3.0.0"
|
||||||
|
info:
|
||||||
|
description: "test"
|
||||||
|
version: "1.0.0"
|
||||||
|
title: "myTest"
|
||||||
|
contact:
|
||||||
|
email: "my@mail.com"
|
||||||
|
servers:
|
||||||
|
- url: "http://localhost:9998/v1"
|
||||||
|
tags:
|
||||||
|
- name: "users"
|
||||||
|
paths:
|
||||||
|
/users/create/{username}:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
operationId: "createUser"
|
||||||
|
parameters:
|
||||||
|
- name: "username"
|
||||||
|
in: "path"
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: "string"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "The User just created"
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/User"
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
User:
|
||||||
|
allOf:
|
||||||
|
- $ref: "#/components/schemas/UserDetail"
|
||||||
|
- type: "object"
|
||||||
|
description: "The User"
|
||||||
|
required:
|
||||||
|
- "userid"
|
||||||
|
- "username"
|
||||||
|
UserDetail:
|
||||||
|
type: "object"
|
||||||
|
description: "Detail of a User"
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: "string"
|
||||||
|
description: "the name of the user"
|
@ -39,3 +39,5 @@ build:
|
|||||||
- ./bin/run-all-petstore
|
- ./bin/run-all-petstore
|
||||||
# generate all petstore samples (openapi3)
|
# generate all petstore samples (openapi3)
|
||||||
- ./bin/openapi3/run-all-petstore
|
- ./bin/openapi3/run-all-petstore
|
||||||
|
# generate test scripts
|
||||||
|
- ./bin/tests/run-all-test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user