[NFC][flang] Fix execute_command_line test for odd environments (#117714)
One of the execute_command_line tests currently runs `cat` on an invalid file and checks its return value, but since we don't control `cat` or the user's path, the return value might not be reliably stable on a per-platform basis. For example, if `git` is installed on Windows in certain configurations it adds a directory to the path containing a `cat` with a different set of error codes to the default Windows one. This patch changes the test to use the `not` binary built by LLVM for testing purposes, which should always return 1 on any platform regardless of the user's environment.
This commit is contained in:
@@ -36,4 +36,6 @@ target_link_libraries(FlangRuntimeTests
|
||||
FortranRuntime
|
||||
)
|
||||
|
||||
target_compile_definitions(FlangRuntimeTests PRIVATE NOT_EXE="$<TARGET_FILE:not>")
|
||||
|
||||
add_subdirectory(CUDA)
|
||||
|
||||
@@ -340,7 +340,7 @@ TEST_F(ZeroArguments, ECLValidCommandStatusSetSync) {
|
||||
}
|
||||
|
||||
TEST_F(ZeroArguments, ECLGeneralErrorCommandErrorSync) {
|
||||
OwningPtr<Descriptor> command{CharDescriptor("cat GeneralErrorCommand")};
|
||||
OwningPtr<Descriptor> command{CharDescriptor(NOT_EXE)};
|
||||
bool wait{true};
|
||||
OwningPtr<Descriptor> exitStat{IntDescriptor(404)};
|
||||
OwningPtr<Descriptor> cmdStat{IntDescriptor(202)};
|
||||
@@ -348,16 +348,14 @@ TEST_F(ZeroArguments, ECLGeneralErrorCommandErrorSync) {
|
||||
|
||||
RTNAME(ExecuteCommandLine)
|
||||
(*command.get(), wait, exitStat.get(), cmdStat.get(), cmdMsg.get());
|
||||
#if defined(_WIN32)
|
||||
CheckDescriptorEqInt<std::int64_t>(exitStat.get(), 1);
|
||||
#if defined(_WIN32)
|
||||
CheckDescriptorEqInt<std::int64_t>(cmdStat.get(), 6);
|
||||
CheckDescriptorEqStr(cmdMsg.get(), "Invalid command lineXXXXXXXXX");
|
||||
#elif defined(_AIX)
|
||||
CheckDescriptorEqInt<std::int64_t>(exitStat.get(), 2);
|
||||
CheckDescriptorEqInt<std::int64_t>(cmdStat.get(), 6);
|
||||
CheckDescriptorEqStr(cmdMsg.get(), "Invalid command lineXXXXXXXXX");
|
||||
#else
|
||||
CheckDescriptorEqInt<std::int64_t>(exitStat.get(), 1);
|
||||
CheckDescriptorEqInt<std::int64_t>(cmdStat.get(), 3);
|
||||
CheckDescriptorEqStr(cmdMsg.get(), "Command line execution failed");
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user