#!/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" for f in TkzCodec TkzArchive TkzSelfTest; do python3 "$here/mql2cpp.py" "$root/lib/$f.mqh" "$build/$f.h" done for f in TkzExport TkzVerify TkzToCustom TkzSelfTest; do python3 "$here/mql2cpp.py" "$root/scripts/$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" cd "$build" 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