diff options
author | Mu Qiao <qiaomuf@gentoo.org> | 2011-06-02 19:27:04 +0800 |
---|---|---|
committer | Mu Qiao <qiaomuf@gentoo.org> | 2011-06-03 21:31:00 +0800 |
commit | 5454166103257b3f19b829dbc2c824ad67acf344 (patch) | |
tree | 20204509efde1d1bb880d37139188e1615eac009 /test | |
parent | Core: fix header ordering (diff) | |
download | libbash-5454166103257b3f19b829dbc2c824ad67acf344.tar.gz libbash-5454166103257b3f19b829dbc2c824ad67acf344.tar.bz2 libbash-5454166103257b3f19b829dbc2c824ad67acf344.zip |
Core: make error handling POSIX compliant
For a non-interactive shell, an error condition encountered by a special
built-in or other type of utility shall cause the shell to write a
diagnostic message to standard error and exit.
Diffstat (limited to 'test')
-rw-r--r-- | test/api_test.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/test/api_test.cpp b/test/api_test.cpp index 7744ebf..38972fe 100644 --- a/test/api_test.cpp +++ b/test/api_test.cpp @@ -40,10 +40,8 @@ TEST(libbashapi, illegal_script) { std::unordered_map<std::string, std::vector<std::string>> variables; std::vector<std::string> functions; - int result = libbash::interpret(get_src_dir() + "/scripts/illegal_script.sh", - variables, - functions); - EXPECT_NE(0, result); + EXPECT_THROW(libbash::interpret(get_src_dir() + "/scripts/illegal_script.sh", variables, functions), + interpreter_exception); } TEST(libbashapi, legal_script) @@ -78,9 +76,10 @@ TEST(libbashapi, preload) variables, functions); EXPECT_NE(0, result); - result = libbash::interpret(get_src_dir() + std::string("/scripts/source_true.sh"), - get_src_dir() + std::string("/scripts/illegal_script.sh"), - variables, - functions); - EXPECT_NE(0, result); + + EXPECT_THROW(libbash::interpret(get_src_dir() + std::string("/scripts/source_true.sh"), + get_src_dir() + std::string("/scripts/illegal_script.sh"), + variables, + functions), + interpreter_exception); } |