From a1c69c6bf35c4f23c773f35962d4e3ba7be8fee4 Mon Sep 17 00:00:00 2001 From: Max Spahn Date: Wed, 2 Mar 2022 16:02:52 +0100 Subject: [PATCH] Test plotting and test res.csv. --- scripts/ci_script.sh | 3 +++ tests/integration_test.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/scripts/ci_script.sh b/scripts/ci_script.sh index 72a7b08..e7c3f3b 100755 --- a/scripts/ci_script.sh +++ b/scripts/ci_script.sh @@ -2,6 +2,9 @@ cd experiments/example ../../plannerbenchmark/exec/runner -c setup/exp.yaml -p pdplanner setup/planner.yaml +resultsFolder=$(ls results/) +resPath="results/${resultsFolder}" +../../plannerbenchmark/exec/postProcessor --exp $resPath --plot -k solverTime clearance --no-open cd ../.. pytest tests rm -r experiments/example/results/pdplanner_* diff --git a/tests/integration_test.py b/tests/integration_test.py index 2b0a33d..a01521e 100644 --- a/tests/integration_test.py +++ b/tests/integration_test.py @@ -1,6 +1,8 @@ import os import pytest import yaml +import csv +import numpy as np def test_resultDirExists(): @@ -17,6 +19,8 @@ def test_resultDirExists(): assert 'res.csv' in filenames assert 'planner.yaml' in filenames assert 'exp.yaml' in filenames + assert 'plots' in filenames + def test_yamlContents(): curDirName = os.path.dirname(os.path.abspath(__file__)) @@ -43,3 +47,29 @@ def test_yamlContents(): expDefaultDict = yaml.safe_load(expStream) assert expDict == expDefaultDict + +def test_plotting(): + curDirName = os.path.dirname(os.path.abspath(__file__)) + resDirName = curDirName + '/../experiments/example/results' + for fname in os.listdir(resDirName): + if os.path.isdir(os.path.join(resDirName,fname)): + resultFolder = os.path.join(resDirName, fname) + plotFolder = os.path.join(resultFolder, 'plots') + filenamesInPlot = os.listdir(plotFolder) + assert 'trajectory.eps' in filenamesInPlot + + +def test_resFile(): + curDirName = os.path.dirname(os.path.abspath(__file__)) + resDirName = curDirName + '/../experiments/example/results' + for fname in os.listdir(resDirName): + if os.path.isdir(os.path.join(resDirName,fname)): + resultFolder = os.path.join(resDirName, fname) + resFileName = os.path.join(resultFolder, 'res.csv') + expectedResultFolder = curDirName + '/../experiments/example/expectedResult/pdplanner_default' + resDefaultFileName = os.path.join(expectedResultFolder, 'res.csv') + resArray = np.genfromtxt(resFileName, delimiter=',', skip_header=1) + resDefaultArray = np.genfromtxt(resDefaultFileName, delimiter=',', skip_header=1) + np.testing.assert_array_almost_equal(resArray[:, 2:], resDefaultArray[:, 2:]) + +