Skip to content

Commit

Permalink
[TEST] Add CLI --timing-output test.
Browse files Browse the repository at this point in the history
  • Loading branch information
smehringer committed Nov 8, 2023
1 parent 62343ec commit d2d2b39
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ target_use_datasources (cli_chopper_pipeline_test FILES seq1.fa)
target_use_datasources (cli_chopper_pipeline_test FILES small.fa)
target_use_datasources (cli_chopper_pipeline_test FILES small2.fa)
target_use_datasources (cli_chopper_pipeline_test FILES small.split)

add_cli_test (cli_timing_output_test.cpp)
target_use_datasources (cli_chopper_pipeline_test FILES small.fa)
45 changes: 45 additions & 0 deletions test/cli/cli_timing_output_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// ---------------------------------------------------------------------------------------------------
// Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin
// Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik
// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
// shipped with this file and also available at: https://github.com/seqan/chopper/blob/main/LICENSE.md
// ---------------------------------------------------------------------------------------------------

#include <gtest/gtest.h>

#include <filesystem>
#include <fstream>
#include <string> // strings

#include <seqan3/test/tmp_directory.hpp>

#include "cli_test.hpp"

TEST_F(cli_test, timing_output)
{
std::string const seq_filename = data("small.fa");
seqan3::test::tmp_directory tmp_dir{};
std::filesystem::path const input_filename{tmp_dir.path() / "data.tsv"};
std::filesystem::path const layout_filename{tmp_dir.path() / "output.layout"};
std::filesystem::path const timing_filename{tmp_dir.path() / "output.timings"};

{
std::ofstream fout{input_filename};
fout << seq_filename << '\n' << seq_filename << '\n' << seq_filename << '\n';
}

cli_test_result result = execute_app("chopper",
"--input",
input_filename.c_str(),
"--output",
layout_filename.c_str(),
"--timing-output",
timing_filename.c_str());

EXPECT_EQ(result.exit_code, 0);
EXPECT_EQ(result.out, std::string{});
EXPECT_EQ(result.err, std::string{});

EXPECT_TRUE(std::filesystem::exists(timing_filename)); // file should have been written
// not not check output since it is not relevant how exectly the timings look like
}

0 comments on commit d2d2b39

Please sign in to comment.