| 5 | namespace sp = subprocess; |
| 6 | |
| 7 | void test_exception() |
| 8 | { |
| 9 | bool caught = false; |
| 10 | try { |
| 11 | auto p = sp::Popen("invalid_command"); |
| 12 | assert(false); // Expected to throw |
| 13 | } catch (sp::CalledProcessError& e) { |
| 14 | #ifdef __USING_WINDOWS__ |
| 15 | assert(std::strstr(e.what(), "CreateProcess failed: The system cannot find the file specified.")); |
| 16 | #else |
| 17 | assert(std::strstr(e.what(), "execve failed: No such file or directory")); |
| 18 | #endif |
| 19 | caught = true; |
| 20 | } |
| 21 | assert(caught); |
| 22 | } |
| 23 | |
| 24 | int main() { |
| 25 | test_exception(); |