Skip to content

Commit 2367739

Browse files
committed
Fix diagonstic file name and add check for diagnostic file name in multi_chain test
1 parent 45a3276 commit 2367739

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/cmdstan/command.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ int command(int argc, const char *argv[]) {
462462
} else {
463463
diagnostic_name = diagnostic_file.substr(0, diagnostic_marker_pos);
464464
diagnostic_ending
465-
= output_file.substr(diagnostic_marker_pos, diagnostic_file.size());
465+
= diagnostic_file.substr(diagnostic_marker_pos, diagnostic_file.size());
466466
}
467467

468468
std::vector<stan::callbacks::unique_stream_writer<std::ostream>>

src/test/interface/multi_chain_test.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ TEST(interface, output_multi) {
1616
= cmdstan::test::convert_model_path(model_path)
1717
+ " id=10 sample num_warmup=200 num_samples=1 num_chains=2 random seed=1234"
1818
+ " output file=" + cmdstan::test::convert_model_path(model_path)
19-
+ ".csv";
19+
+ ".csv diagnostic_file=" + cmdstan::test::convert_model_path(model_path) + "_diag.csv";
2020

2121
cmdstan::test::run_command_output out = cmdstan::test::run_command(command);
2222
EXPECT_EQ(int(stan::services::error_codes::OK), out.err_code);
@@ -41,6 +41,9 @@ TEST(interface, output_multi) {
4141
for (size_t i = 0; i < 9; ++i) {
4242
EXPECT_EQ(names[i], chain_param_names[i]);
4343
}
44+
std::string diag_name = cmdstan::test::convert_model_path(model_path) + "_diag_10.csv";
45+
std::ifstream diag_file(diag_name);
46+
EXPECT_TRUE(diag_file.good());
4447
}
4548
{
4649
std::string csv_file
@@ -62,5 +65,8 @@ TEST(interface, output_multi) {
6265
for (size_t i = 0; i < 9; ++i) {
6366
EXPECT_EQ(names[i], chain_param_names[i]);
6467
}
68+
std::string diag_name = cmdstan::test::convert_model_path(model_path) + "_diag_11.csv";
69+
std::ifstream diag_file(diag_name);
70+
EXPECT_TRUE(diag_file.good());
6571
}
6672
}

0 commit comments

Comments
 (0)