Skip to content

Commit 495f521

Browse files
authored
Merge pull request SQFvm#206 from DarkWanderer/ctest-fix
Fixed ctest to correctly execute SQF using existing framework
2 parents 1e8939e + d8440f2 commit 495f521

File tree

8 files changed

+315
-31
lines changed

8 files changed

+315
-31
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ jobs:
2222
path: build/sqfvm*
2323

2424
- name: Run SQF-VM Tests
25-
run: cd build && ctest
25+
working-directory: build
26+
run: ctest --output-on-failure
2627

2728
- name: Run CBA A3 Tests
2829
run: PATH=build:$PATH python tests/cba/cba_a3.py
@@ -46,7 +47,8 @@ jobs:
4647
path: build/sqfvm*
4748

4849
- name: Run SQF-VM Tests
49-
run: cd build && ctest
50+
working-directory: build
51+
run: ctest --output-on-failure
5052

5153
- name: Run CBA A3 Tests
5254
run: PATH=build:$PATH python tests/cba/cba_a3.py
@@ -67,7 +69,8 @@ jobs:
6769
path: build/sqfvm*
6870

6971
- name: Run SQF-VM Tests
70-
run: cd build && ctest
72+
working-directory: build
73+
run: ctest --output-on-failure
7174

7275
- name: Run CBA A3 Tests
7376
run: PATH=build:$PATH python tests/cba/cba_a3.py
@@ -88,7 +91,8 @@ jobs:
8891
path: build/Release/*.exe
8992

9093
- name: Run SQF-VM Tests
91-
run: cd build && ctest -C Release
94+
working-directory: build
95+
run: ctest --output-on-failure -C Release
9296

9397
- name: Run CBA A3 Tests
9498
run: |
@@ -111,7 +115,8 @@ jobs:
111115
path: build/Release/*.exe
112116

113117
- name: Run SQF-VM Tests
114-
run: cd build && ctest -C Release
118+
working-directory: build
119+
run: ctest --output-on-failure -C Release
115120

116121
- name: Run CBA A3 Tests
117122
run: |

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,3 +353,5 @@ build/git_sha1\.cpp
353353

354354
*.diagsession
355355
src/sqc/parser.output
356+
/tests/_out1_.txt
357+
/tests/_err1_.txt

src/cli/cli.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ void cli::handle_files()
4646
auto [path, contents] = generator();
4747
if (key == "sqf")
4848
{
49-
if (verbose()) { std::cout << "Preprocessing file '" << path << std::endl; }
49+
if (verbose()) { std::cout << "Preprocessing file '" << path << "'" << std::endl; }
5050
auto ppedStr = m_runtime.parser_preprocessor().preprocess(m_runtime, contents, { path.string(), {} });
5151
if (ppedStr.has_value())
5252
{
53-
if (verbose()) { std::cout << "Parsing file '" << path << std::endl; }
53+
if (verbose()) { std::cout << "Parsing file '" << path << "'" << std::endl; }
5454
if (m_parse_only)
5555
{
5656
auto success = m_runtime.parser_sqf().check_syntax(m_runtime, *ppedStr, { path.string(), {} });
@@ -82,11 +82,11 @@ void cli::handle_files()
8282
}
8383
else if (key == "config")
8484
{
85-
if (verbose()) { std::cout << "Preprocessing file '" << path << std::endl; }
85+
if (verbose()) { std::cout << "Preprocessing file '" << path << "'" << std::endl; }
8686
auto ppedStr = m_runtime.parser_preprocessor().preprocess(m_runtime, contents, { path.string(), {} });
8787
if (ppedStr.has_value())
8888
{
89-
if (verbose()) { std::cout << "Parsing file '" << path << std::endl; }
89+
if (verbose()) { std::cout << "Parsing file '" << path << "'" << std::endl; }
9090
if (m_parse_only)
9191
{
9292
auto success = !m_runtime.parser_config().check_syntax(*ppedStr, { path.string(), {} });
@@ -112,11 +112,11 @@ void cli::handle_files()
112112
else if (key == "sqc")
113113
{
114114
sqf::sqc::parser sqc_parser(m_logger);
115-
if (verbose()) { std::cout << "Preprocessing file '" << path << std::endl; }
115+
if (verbose()) { std::cout << "Preprocessing file '" << path << "'" << std::endl; }
116116
auto ppedStr = m_runtime.parser_preprocessor().preprocess(m_runtime, contents, { path.string(), {} });
117117
if (ppedStr.has_value())
118118
{
119-
if (verbose()) { std::cout << "Parsing file '" << path << std::endl; }
119+
if (verbose()) { std::cout << "Parsing file '" << path << "'" << std::endl; }
120120
if (m_parse_only)
121121
{
122122
auto success = sqc_parser.check_syntax(m_runtime, *ppedStr, { path.string(), {} });
@@ -148,11 +148,11 @@ void cli::handle_files()
148148
}
149149
else if (key == "sqf2sqc")
150150
{
151-
if (verbose()) { std::cout << "Preprocessing file '" << path << std::endl; }
151+
if (verbose()) { std::cout << "Preprocessing file '" << path << "'" << std::endl; }
152152
auto ppedStr = m_runtime.parser_preprocessor().preprocess(m_runtime, contents, { path.string(), {} });
153153
if (ppedStr.has_value())
154154
{
155-
if (verbose()) { std::cout << "Parsing file '" << path << std::endl; }
155+
if (verbose()) { std::cout << "Parsing file '" << path << "'" << std::endl; }
156156
if (m_parse_only)
157157
{
158158
auto success = m_runtime.parser_sqf().check_syntax(m_runtime, *ppedStr, { path.string(), {} });
@@ -193,11 +193,11 @@ void cli::handle_files()
193193
else if (key == "sqc2sqf")
194194
{
195195
sqf::sqc::parser sqc_parser(m_logger);
196-
if (verbose()) { std::cout << "Preprocessing file '" << path << std::endl; }
196+
if (verbose()) { std::cout << "Preprocessing file '" << path << "'" << std::endl; }
197197
auto ppedStr = m_runtime.parser_preprocessor().preprocess(m_runtime, contents, { path.string(), {} });
198198
if (ppedStr.has_value())
199199
{
200-
if (verbose()) { std::cout << "Parsing file '" << path << std::endl; }
200+
if (verbose()) { std::cout << "Parsing file '" << path << "'" << std::endl; }
201201
if (m_parse_only)
202202
{
203203
auto success = sqc_parser.check_syntax(m_runtime, *ppedStr, { path.string(), {} });
@@ -412,7 +412,7 @@ int cli::run(size_t argc, const char** argv)
412412

413413
// Preprocessing
414414
CMDADD(TCLAP::MultiArg<std::string>, preprocessFileArg, "E", "preprocess-file", "Runs the preprocessor on provided file and prints it to stdout. " RELPATHHINT "!BE AWARE! This is case-sensitive!", false, "PATH");
415-
CMDADD(TCLAP::MultiArg<std::string>, defineArg, "D", "define", "Allows to add PreProcessor definitions. Note that file-based definitions may override and/or conflict with theese.", false, "NAME|NAME=VALUE");
415+
CMDADD(TCLAP::MultiArg<std::string>, defineArg, "D", "define", "Allows to add PreProcessor definitions. Note that file-based definitions may override and/or conflict with these.", false, "NAME|NAME=VALUE");
416416

417417
// Dummy Operators
418418
CMDADD(TCLAP::MultiArg<std::string>, commandDummyNular, "", "command-dummy-nular", "Adds the provided command as dummy.", false, "NAME");
@@ -679,7 +679,7 @@ int cli::run(size_t argc, const char** argv)
679679
continue;
680680
}
681681
auto str = *file;
682-
if (verbose()) { std::cout << "Preprocessing file '" << path << std::endl; }
682+
if (verbose()) { std::cout << "Preprocessing file '" << path << "'" << std::endl; }
683683
auto ppedStr = m_runtime.parser_preprocessor().preprocess(m_runtime, str, { path.string(), {} });
684684
if (ppedStr.has_value())
685685
{

src/sqc/ReadMe.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Instead, SQC attempts to automatically mangle the different types and functions
7070

7171
For example, a call to `diag_log` in SQC, treats `diag_log` as method which makes the call look like this: `diag_log("fooo bar")`.
7272
special attention should be given to operators, expecting arrays as their parameter though.
73-
For theese, SQC automatically transforms parameter lists into arrays (`nearestObjects(player, ["Tank"],500)`) however, given that only one argument
73+
For these, SQC automatically transforms parameter lists into arrays (`nearestObjects(player, ["Tank"],500)`) however, given that only one argument
7474
gets passed to an operator expecting an array, the correct way to call that then is to pass the array then as a proper array (`private(["_someVar"])`)
7575

7676
With Binary operators (eg. `in`), SQC gives you a somewhat OOP way to access them, making `player setPosition [1,2,3]` to `player.setPosition(1,2,3)`.
@@ -139,7 +139,7 @@ In SQC, a function is made using the following syntax:
139139
```
140140
### Function Args
141141
`<ARGS>` are a comma separated list of "arguments" that the method shall receive.
142-
Theese can be typed. They follow the following syntax:
142+
these can be typed. They follow the following syntax:
143143

144144
```js
145145
variableName
@@ -157,7 +157,7 @@ existing variables in the function code. This is what that syntax does. It rewri
157157

158158
Full example: `arr.select(function(it: "_x") { return it > 2; });` gets `arr select { _x > 2 }`
159159
## File Header
160-
SQC Files may start with a so called "params" directive. This is so, that CfgFunctions may be used to initialize theese methods.
160+
SQC Files may start with a so called "params" directive. This is so, that CfgFunctions may be used to initialize these methods.
161161
It lends itself the comma separated list of `<ARGS>` known from Functions and looks like this:
162162

163163
```js

tests/CMakeLists.txt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# Register all .sqf tests
22

3-
set(TEST_CONFIG_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/config.cpp)
3+
set(TEST_ROOT_LOCATION ${CMAKE_CURRENT_SOURCE_DIR})
44

55
function(add_sqf_run_test test_full_path)
66
get_filename_component(test_name ${test_full_path} NAME_WE)
7+
file(RELATIVE_PATH test_relative_path ${TEST_ROOT_LOCATION} ${test_full_path})
78
set(test_full_name run.${test_name})
89

9-
message("Registering test " ${test_full_path} " as " ${test_full_name})
10+
message(VERBOSE "Registering test " ${test_full_path} " as " ${test_full_name})
1011
add_test(
1112
NAME "${test_full_name}"
12-
COMMAND sqfvm -a -V --no-execute-print --input-sqf ${test_full_path} --input-config ${TEST_CONFIG_LOCATION} --max-runtime 10000
13-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
13+
COMMAND sqfvm -a -V --no-execute-print --max-runtime 1000
14+
--input-sqf "framework.sqf" --input-config ${TEST_ROOT_LOCATION}/config.cpp
15+
--sqf "\"${test_relative_path}\" call test_fnc_run_from_file;"
16+
WORKING_DIRECTORY ${TEST_ROOT_LOCATION}
1417
)
1518
set_tests_properties(${test_full_name} PROPERTIES TIMEOUT 11)
1619
endfunction()
@@ -19,14 +22,14 @@ function(add_sqf_preprocess_test test_full_path)
1922
get_filename_component(test_name ${test_full_path} NAME_WE)
2023
set(test_full_name preprocess.${test_name})
2124

22-
message("Registering test " ${test_full_path} " as " ${test_full_name})
25+
message(VERBOSE "Registering test " ${test_full_path} " as " ${test_full_name})
2326
add_test(
2427
NAME "${test_full_name}"
25-
COMMAND sqfvm -a -V --no-execute-print --preprocess-file ${test_full_path} --input-config ${TEST_CONFIG_LOCATION} --max-runtime 10000
26-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
28+
COMMAND sqfvm -a -V --no-execute-print --preprocess-file ${test_full_path} --input-config ${TEST_ROOT_LOCATION}/config.cpp --max-runtime 10000
29+
WORKING_DIRECTORY ${TEST_ROOT_LOCATION}
2730
)
2831
endfunction()
2932

3033
add_subdirectory(sqf)
3134
add_subdirectory(preprocess)
32-
add_subdirectory(cba)
35+
add_subdirectory(cba)

tests/ReadMe.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ The test-framework depends heavily on SQF-VM own commands and can be used as a r
55
implementation (or straight copied) for your own Test-Framework using SQF-VM.
66

77
Due to features like `assertException` expecting runtime-errors and Arma not being able to handle
8-
theese, this test-framework can be deemed as incompatible to Arma.
8+
these, this test-framework can be deemed as incompatible to Arma.
99

1010
## Executing Tests ##
1111

12-
To run theese tests, start SQF-VM with the following commands:
12+
To run these tests, start SQF-VM with the following commands:
1313

1414
`-a -i tests/config.cpp -i tests/runTests.sqf`
1515

tests/cba/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
add_sqf_run_test(${CMAKE_CURRENT_SOURCE_DIR}/cba_a3.sqf)
1+
# add_sqf_run_test(${CMAKE_CURRENT_SOURCE_DIR}/cba_a3.sqf)

0 commit comments

Comments
 (0)