Skip to content

Commit

Permalink
Correctly set the working directory when executing Python test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
dandersonappsecai committed Feb 21, 2024
1 parent 4ca0d58 commit 161e165
Showing 1 changed file with 3 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,22 +309,19 @@ static ResponseInfo sendRequest(CloseableHttpClient httpclient, HttpUriRequest r
* and the global variable timeString the URL tested, the time required to execute and the
* response code.
*
* @param httpclient - The HTTP client to use to make the request
* @param request - THe HTTP request to issue
* @param request - THe CLI request to issue
*/
static ResponseInfo execute(CliRequest request) {
CliResponseInfo responseInfo = new CliResponseInfo();
responseInfo.setRequest(request);
// responseInfo.setRequestBase(request);
CloseableHttpResponse response = null;

ArrayList<String> executeArgs =
new ArrayList<>(Arrays.asList(request.getCommand().split(" ")));
for (RequestVariable arg : request.getArgs()) {
executeArgs.add(arg.getName());
// System.out.println("Adding arg: " + arg.getValue());
executeArgs.add(arg.getValue());
}
// executeArgs.addAll(request.getArgs());
System.out.println(String.join(" ", executeArgs));

StopWatch watch = new StopWatch();
Expand All @@ -333,6 +330,7 @@ static ResponseInfo execute(CliRequest request) {
try {
// response = httpclient.execute(request);
ProcessBuilder builder = new ProcessBuilder(executeArgs);
builder.directory(new File("../../julietpy/testcode"));
builder.inheritIO();
final Process process = builder.start();
final BufferedReader reader =
Expand All @@ -351,28 +349,6 @@ static ResponseInfo execute(CliRequest request) {
}
watch.stop();

// try {
// HttpEntity entity = response.getEntity();
// int statusCode = response.getCode();
// responseInfo.setStatusCode(statusCode);
// int seconds = (int) watch.getTime() / 1000;
// responseInfo.setTimeInSeconds(seconds);
// System.out.printf("--> (%d : %d sec)%n", statusCode, seconds);
//
// try {
// responseInfo.setResponseString(EntityUtils.toString(entity));
// EntityUtils.consume(entity);
// } catch (IOException | org.apache.hc.core5.http.ParseException e) {
// e.printStackTrace();
// }
// } finally {
// if (response != null)
// try {
// response.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
return responseInfo;
}

Expand Down

0 comments on commit 161e165

Please sign in to comment.