|
1 | | -#include <cmdstan/stansummary_helper.hpp> |
2 | | -#include <stan/io/stan_csv_reader.hpp> |
3 | | -#include <stan/services/error_codes.hpp> |
4 | 1 | #include <test/utility.hpp> |
5 | 2 | #include <gtest/gtest.h> |
6 | 3 |
|
7 | 4 | using cmdstan::test::convert_model_path; |
| 5 | +using cmdstan::test::run_command; |
| 6 | +using cmdstan::test::temporary_unwritable_file; |
8 | 7 |
|
9 | | -TEST(interface, unwritable_file) { |
10 | | - std::string model = convert_model_path( |
11 | | - std::vector{"src", "test", "test-models", "test_model"}); |
12 | | - std::string output |
13 | | - = convert_model_path(std::vector{"test", "output_unwritable.csv"}); |
| 8 | +TEST(interface, fails_when_output_is_unwritable) { |
| 9 | + // makes a file without the w bit set |
| 10 | + temporary_unwritable_file file( |
| 11 | + convert_model_path(std::vector{"test", "output_unwritable.csv"})); |
14 | 12 |
|
15 | | - cmdstan::test::temporary_unwritable_file guard(output); |
| 13 | + std::string command = convert_model_path(std::vector{ |
| 14 | + "src", "test", "test-models", "test_model"}) |
| 15 | + + " sample output file=" + file.filename; |
16 | 16 |
|
17 | | - std::string command |
18 | | - = model + " sample num_warmup=1 num_samples=1 output file=" + output; |
19 | | - |
20 | | - cmdstan::test::run_command_output out = cmdstan::test::run_command(command); |
| 17 | + auto out = run_command(command); |
21 | 18 | EXPECT_IN_STRING("Permission denied", out.output); |
22 | 19 | EXPECT_TRUE(out.hasError); |
23 | 20 | } |
0 commit comments