Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,6 @@ if (SQFVM_BUILD_STATIC_LIBRARY_SQC_SUPPORT)
/W4>)
SET_TARGET_PROPERTIES(slibsqfvm_sqc PROPERTIES PREFIX "")
endif ()

enable_testing()
add_subdirectory(tests)
7 changes: 6 additions & 1 deletion src/cli/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,12 @@ int cli::cli_from_file(const char* arg0, std::filesystem::path path)
}
catch (std::runtime_error& err)
{
std::cout << err.what() << std::endl;
std::cerr << err.what() << std::endl;
return -1;
}
catch (...)
{
std::cerr << "Unknown exception" << std::endl;
return -1;
}
}
Expand Down
12 changes: 10 additions & 2 deletions src/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ int main(int argc, char** argv)
auto res = main_actual(argc, argv);
return res;
}

int main_actual(int argc, char** argv)
{
#ifdef WIN32
Expand All @@ -126,6 +127,13 @@ int main_actual(int argc, char** argv)
}
#endif // DF__CLI_PRINT_INPUT_ARGS

cli command_line_interface;
return command_line_interface.run(argc, const_cast<const char**>(argv));
try {
cli command_line_interface;
return command_line_interface.run(argc, const_cast<const char**>(argv));
}
catch (std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return -1;
}
}
2 changes: 1 addition & 1 deletion src/runtime/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2764,7 +2764,7 @@ namespace logmessage::runtime
}
std::string ContextValuePrint::formatMessage() const
{
const auto messageA = "Context droped with return value `"sv;
const auto messageA = "Context dropped with return value `"sv;
const auto messageB = "`."sv;
auto value_sqf = value.to_string_sqf();

Expand Down
32 changes: 32 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Register all .sqf tests

set(TEST_CONFIG_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/config.cpp)

function(add_sqf_run_test test_full_path)
get_filename_component(test_name ${test_full_path} NAME_WE)
set(test_full_name run.${test_name})

message("Registering test " ${test_full_path} " as " ${test_full_name})
add_test(
NAME "${test_full_name}"
COMMAND sqfvm -a -V --no-execute-print --input-sqf ${test_full_path} --input-config ${TEST_CONFIG_LOCATION} --max-runtime 10000
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
set_tests_properties(${test_full_name} PROPERTIES TIMEOUT 11)
endfunction()

function(add_sqf_preprocess_test test_full_path)
get_filename_component(test_name ${test_full_path} NAME_WE)
set(test_full_name preprocess.${test_name})

message("Registering test " ${test_full_path} " as " ${test_full_name})
add_test(
NAME "${test_full_name}"
COMMAND sqfvm -a -V --no-execute-print --preprocess-file ${test_full_path} --input-config ${TEST_CONFIG_LOCATION} --max-runtime 10000
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endfunction()

add_subdirectory(sqf)
add_subdirectory(preprocess)
add_subdirectory(cba)
1 change: 1 addition & 0 deletions tests/cba/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_sqf_run_test(${CMAKE_CURRENT_SOURCE_DIR}/cba_a3.sqf)
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions tests/preprocess/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
file(GLOB_RECURSE test_script_files "*.sqf")
foreach(test_full_path ${test_script_files})
add_sqf_preprocess_test(${test_full_path})
endforeach()
4 changes: 4 additions & 0 deletions tests/sqf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
file(GLOB_RECURSE test_script_files "*.sqf")
foreach(test_full_path ${test_script_files})
add_sqf_run_test(${test_full_path})
endforeach()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.