2026-11-06 16:07:23 -08:00 | | | #!/usr/bin/env bash
|
| | | # Translate the MQL5 library to C++, build the test driver and run it.
|
| | | # tests/run_tests.sh [tick files...]
|
| | | # Environment:
|
| | | # CXX C++ compiler command (default: c++; e.g. "zig c++")
|
| | | # BUILD_DIR build directory (default: tests/build)
|
| | | set -euo pipefail
|
| | | here="$(cd "$(dirname "$0")" && pwd)"
|
| | | root="$(cd "$here/.." && pwd)"
|
| | | build="${BUILD_DIR:-$here/build}"
|
| | | cxx="${CXX:-c++}"
|
| | | mkdir -p "$build" "$build/files"
|
2026-11-06 16:16:49 -08:00 | | | for f in TkzCodec TkzArchive TkzSelfTest; do
|
2026-11-06 16:07:23 -08:00 | | | python3 "$here/mql2cpp.py" "$root/MQL5/Include/Tkz/$f.mqh" "$build/$f.h"
|
| | | done
|
2026-11-06 17:06:47 -08:00 | | | for f in TkzExport TkzVerify TkzToCustom TkzSelfTest; do
|
| | | python3 "$here/mql2cpp.py" "$root/MQL5/Scripts/Tkz/$f.mq5" "$build/script_$f.h"
|
| | | done
|
| | | flags=(-std=c++17 -O2 -fwrapv -Wall -Wextra -Wno-unused-parameter -I"$here" -I"$build")
|
| | | $cxx "${flags[@]}" -o "$build/test_codec" "$here/test_codec.cpp"
|
| | | $cxx "${flags[@]}" -o "$build/test_scripts" "$here/test_scripts.cpp"
|
2026-11-06 16:07:23 -08:00 | | | cd "$build"
|
2026-11-06 17:06:47 -08:00 | | | export MQL5_FILES_DIR="$build/files"
|
| | | ./test_codec "$@"
|
| | | # the script test needs one forex-like history file (defaults to the EURUSD sample)
|
| | | script_data="${SCRIPT_TICKS:-}"
|
| | | if [ -z "$script_data" ]; then
|
| | | for f in "$@"; do case "$f" in *eurusd*) script_data="$f";; esac; done
|
| | | fi
|
| | | if [ -n "$script_data" ]; then
|
| | | ./test_scripts "$script_data" EURUSD 5
|
| | | else
|
| | | echo "(script tests skipped: no EURUSD tick file given, set SCRIPT_TICKS=file.ticks)"
|
| | | fi
|