Unverified Commit 25a59eeb authored by Jesse Mapel's avatar Jesse Mapel Committed by GitHub
Browse files

Added temp dir for test files (#3692)

* Added temp dir for test files

* Moved to fixture inheritance

* Added valid check

* Updated tests to use new fixtures

* Fixed build errors

* Fixed build warning

* Updated winnow test
parent 3cea8356
Loading
Loading
Loading
Loading
+12 −15
Original line number Diff line number Diff line
#include <QTemporaryFile>
#include <QTextStream>
#include <QStringList>
#include <QFile>

#include "campt.h"
#include "Fixtures.h"
@@ -17,14 +17,13 @@ static QString APP_XML = FileName("$ISISROOT/bin/xml/campt.xml").expanded();
TEST_F(DefaultCube, FunctionalTestCamptBadColumnError) {
  // set up bad coordinates file
  std::ofstream of;
  QTemporaryFile badList;
  ASSERT_TRUE(badList.open());
  of.open(badList.fileName().toStdString());
  of.open(tempDir.path().toStdString()+"/badList.lis");
  of << "1, 10,\n10,100,500\n100";
  of.close();

  // configure UserInterface arguments
  QVector<QString> args = {"to=output.pvl", "coordlist=" + badList.fileName(),
  QVector<QString> args = {"to=" + tempDir.path()+"/output.pvl",
                           "coordlist=" + tempDir.path()+"/badList.lis",
                           "coordtype=image"};
  UserInterface options(APP_XML, args);
  Pvl appLog;
@@ -191,11 +190,10 @@ TEST_F(DefaultCube, FunctionalTestCamptSetGround) {


TEST_F(DefaultCube, FunctionalTestCamptFlat) {
  // Setup output file
  QTemporaryFile flatFile;
  flatFile.open();

  QVector<QString> args = {"format=flat", "to=" + flatFile.fileName(), "append=false"};
  QFile flatFile(tempDir.path()+"/testOut.txt");
  QVector<QString> args = {"format=flat",
                           "to="+flatFile.fileName(),
                           "append=false"};
  UserInterface options(APP_XML, args);
  Pvl appLog;

@@ -221,14 +219,13 @@ TEST_F(DefaultCube, FunctionalTestCamptFlat) {

TEST_F(DefaultCube, FunctionalTestCamptCoordList) {
  std::ofstream of;
  QTemporaryFile badPointList;
  ASSERT_TRUE(badPointList.open());
  of.open(badPointList.fileName().toStdString());
  of.open(tempDir.path().toStdString()+"/coords.txt");
  of << "1, 10\n10, 100\n 100, 10000";
  of.close();

  QVector<QString> args = {"coordlist=" + badPointList.fileName(),
    "append=false", "coordtype=image"};
  QVector<QString> args = {"coordlist="+tempDir.path()+"/coords.txt",
                           "append=false",
                           "coordtype=image"};
  UserInterface options(APP_XML, args);
  Pvl appLog;

+2 −6
Original line number Diff line number Diff line
#include <iostream>
#include <QTemporaryDir>

#include "cnetwinnow.h"

@@ -20,10 +19,7 @@ using namespace Isis;
static QString APP_XML = FileName("$ISISROOT/bin/xml/cnetwinnow.xml").expanded();

TEST_F(ThreeImageNetwork, FunctionalTestCnetwinnowDefault) {
  QTemporaryDir prefix;
  ASSERT_TRUE(prefix.isValid());

  QString onetPath = prefix.path()+"/winnowedNetwork.net";
  QString onetPath = tempDir.path()+"/winnowedNetwork.net";
  QVector<QString> args = {"onet="+onetPath,
                           "file_prefix=winnow"};
  UserInterface ui(APP_XML, args);
@@ -44,7 +40,7 @@ TEST_F(ThreeImageNetwork, FunctionalTestCnetwinnowDefault) {
    }
  }

  SerialNumberList serialNumList(cubeListTempPath.fileName(), true);
  SerialNumberList serialNumList(cubeListFile, true);
  cnetwinnow(*network, serialNumList, ui);

  int postWinnowMeasureCount = network->GetNumValidMeasures();
+19 −12
Original line number Diff line number Diff line
@@ -2,14 +2,21 @@

namespace Isis {

  void TempTestingFiles::SetUp() {
    ASSERT_TRUE(tempDir.isValid());
  }


  void DefaultCube::SetUp() {
    TempTestingFiles::SetUp();

    std::ifstream isdFile("data/defaultImage/defaultCube.isd");
    std::ifstream cubeLabel("data/defaultImage/defaultCube.pvl");
    isdFile >> isd;
    cubeLabel >> label;

    testCube = new Cube();
    testCube->fromIsd(tempFile.fileName() + ".cub", label, isd, "rw");
    testCube->fromIsd(tempDir.path() + "/default.cub", label, isd, "rw");
  }


@@ -17,10 +24,13 @@ namespace Isis {
    if (testCube->isOpen()) {
      testCube->close();
    }
    delete testCube;
  }


  void ThreeImageNetwork::SetUp() {
    TempTestingFiles::SetUp();

    FileName labelPath1("data/threeImageNetwork/cube1.pvl");
    FileName labelPath2("data/threeImageNetwork/cube2.pvl");
    FileName labelPath3("data/threeImageNetwork/cube3.pvl");
@@ -30,24 +40,21 @@ namespace Isis {
    FileName isdPath3("data/threeImageNetwork/cube3.isd");

    cube1 = new Cube();
    cubeTempPath1.open();
    cube1->fromIsd(cubeTempPath1.fileName() + ".cub", labelPath1, isdPath1, "rw");
    cube1->fromIsd(tempDir.path() + "/cube1.cub", labelPath1, isdPath1, "rw");

    cube2 = new Cube();
    cubeTempPath2.open();
    cube2->fromIsd(cubeTempPath2.fileName() + ".cub", labelPath2, isdPath2, "rw");
    cube2->fromIsd(tempDir.path() + "/cube2.cub", labelPath2, isdPath2, "rw");

    cube3 = new Cube();
    cubeTempPath3.open();
    cube3->fromIsd(cubeTempPath3.fileName() + ".cub", labelPath3, isdPath3, "rw");
    cube3->fromIsd(tempDir.path() + "/cube3.cub", labelPath3, isdPath3, "rw");

    cubeList = new FileList();
    cubeList->append(cube1->fileName());
    cubeList->append(cube2->fileName());
    cubeList->append(cube3->fileName());

    cubeListTempPath.open();
    cubeList->write(cubeListTempPath.fileName());
    cubeListFile = tempDir.path() + "/cubes.lis";
    cubeList->write(cubeListFile);

    network = new ControlNet();
    network->ReadControl("data/threeImageNetwork/controlnetwork.net");
+29 −26
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
#include <string>

#include <QString>
#include <QTemporaryFile>
#include <QTemporaryDir>

#include <nlohmann/json.hpp>

@@ -23,10 +23,17 @@ using json = nlohmann::json;

namespace Isis {

   class DefaultCube : public ::testing::Test {
  class TempTestingFiles : public ::testing::Test {
    protected:
      QTemporaryDir tempDir;

      void SetUp() override;
  };


  class DefaultCube : public TempTestingFiles {
    protected:
      Cube *testCube;
        QTemporaryFile tempFile;

      Pvl label;
      json isd;
@@ -36,7 +43,7 @@ namespace Isis {
  };


   class ThreeImageNetwork : public ::testing::Test {
  class ThreeImageNetwork : public TempTestingFiles {
    protected:

      ControlNet *network;
@@ -46,11 +53,7 @@ namespace Isis {
      Cube *cube3;

      FileList *cubeList;

        QTemporaryFile cubeTempPath1;
        QTemporaryFile cubeTempPath2;
        QTemporaryFile cubeTempPath3;
        QTemporaryFile cubeListTempPath; 
      QString cubeListFile;

      void SetUp() override;
      void TearDown() override;
+1 −5
Original line number Diff line number Diff line
#include <QTemporaryDir>
#include <iostream>

#include "Pvl.h"
@@ -14,10 +13,7 @@ using namespace Isis;
static QString APP_XML = FileName("$ISISROOT/bin/xml/cnetbin2pvl.xml").expanded();

TEST_F(ThreeImageNetwork, FunctionalTestCnetbin2pvlDefault) {
  QTemporaryDir prefix;
  ASSERT_TRUE(prefix.isValid());

  QString pvlOut = prefix.path()+"/cnetbin2pvlNetwork.pvl";
  QString pvlOut = tempDir.path()+"/cnetbin2pvlNetwork.pvl";

  QVector<QString> args = {"to="+pvlOut};
  UserInterface ui(APP_XML, args);
Loading