88#include < cstdio>
99#include < cstdlib>
1010#include < fstream>
11+ #include < unistd.h>
1112#include < memory>
1213#include < sstream>
1314#include < string>
@@ -85,9 +86,16 @@ std::string get_cli_path() {
8586 return " ./build/bin/sonare" ;
8687}
8788
89+ // / @brief Generates a unique temp file path for this test process.
90+ std::string unique_temp_path (const std::string& suffix) {
91+ static int counter = 0 ;
92+ return " /tmp/sonare_cli_test_" + std::to_string (getpid ()) + " _" +
93+ std::to_string (counter++) + suffix;
94+ }
95+
8896const std::string CLI = get_cli_path();
89- const std::string TEST_WAV = " /tmp/sonare_cli_test .wav" ;
90- const std::string TEST_OUT = " /tmp/sonare_cli_out .wav" ;
97+ const std::string TEST_WAV = unique_temp_path( " .wav" ) ;
98+ const std::string TEST_OUT = unique_temp_path( " _out .wav" ) ;
9199
92100} // namespace
93101
@@ -527,7 +535,7 @@ TEST_CASE("CLI time-stretch command", "[cli]") {
527535
528536TEST_CASE (" CLI hpss command" , " [cli]" ) {
529537 create_test_wav (TEST_WAV);
530- std::string out_base = " /tmp/sonare_hpss " ;
538+ std::string out_base = unique_temp_path ( " _hpss " ) ;
531539 std::remove ((out_base + " _harmonic.wav" ).c_str ());
532540 std::remove ((out_base + " _percussive.wav" ).c_str ());
533541
@@ -542,7 +550,7 @@ TEST_CASE("CLI hpss command", "[cli]") {
542550 }
543551
544552 SECTION (" harmonic only" ) {
545- std::string out = " /tmp/sonare_hpss_h .wav" ;
553+ std::string out = unique_temp_path ( " _hpss_h .wav" ) ;
546554 std::remove (out.c_str ());
547555 auto [code, output] =
548556 exec_command (CLI + " hpss --harmonic-only " + TEST_WAV + " -o " + out + " -q" );
@@ -553,7 +561,7 @@ TEST_CASE("CLI hpss command", "[cli]") {
553561 }
554562
555563 SECTION (" percussive only" ) {
556- std::string out = " /tmp/sonare_hpss_p .wav" ;
564+ std::string out = unique_temp_path ( " _hpss_p .wav" ) ;
557565 std::remove (out.c_str ());
558566 auto [code, output] =
559567 exec_command (CLI + " hpss --percussive-only " + TEST_WAV + " -o " + out + " -q" );
0 commit comments