From 9ad2adfb54aea99761784e7b90b3b2f74d63c144 Mon Sep 17 00:00:00 2001 From: kenorb Date: Mon, 9 Sep 2024 22:02:24 +0100 Subject: [PATCH] Moves Backtest class to subdir --- .github/workflows/test-platform-backtest.yml | 72 +++++++++++++++++++ Platform/{ => Backtest}/Backtest.h | 2 +- .../{ => Backtest}/tests/Backtest.test.cpp | 0 .../{ => Backtest}/tests/Backtest.test.mq4 | 0 .../{ => Backtest}/tests/Backtest.test.mq5 | 2 +- Platform/Backtest/tests/Makefile | 12 ++++ tests/CompileTest.mq5 | 1 + 7 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test-platform-backtest.yml rename Platform/{ => Backtest}/Backtest.h (98%) rename Platform/{ => Backtest}/tests/Backtest.test.cpp (100%) rename Platform/{ => Backtest}/tests/Backtest.test.mq4 (100%) rename Platform/{ => Backtest}/tests/Backtest.test.mq5 (98%) create mode 100644 Platform/Backtest/tests/Makefile diff --git a/.github/workflows/test-platform-backtest.yml b/.github/workflows/test-platform-backtest.yml new file mode 100644 index 000000000..ac3824d91 --- /dev/null +++ b/.github/workflows/test-platform-backtest.yml @@ -0,0 +1,72 @@ +--- +name: Test Platform/Backtest + +env: + TEST_PATH: Platform/Backtest/tests + TEST_SKIP: ${{ secrets.MT5_LOGIN == '' }} + +# yamllint disable-line rule:truthy +on: + pull_request: + paths: + - .github/workflows/test-platform-backtest.yml + - Platform/Backtest/** + push: + paths: + - .github/workflows/test-platform-backtest.yml + - Platform/Backtest/** + +jobs: + + compile: + name: Compile + uses: ./.github/workflows/compile-mql.yml + with: + artifact_prefix: mt + path: Platform/Backtest/tests + skip_cleanup: true + + test: + defaults: + run: + shell: bash + working-directory: ${{ env.TEST_PATH }} + name: Test + needs: compile + runs-on: ubuntu-latest + strategy: + matrix: + test: + - Backtest.test + version: [5] + max-parallel: 4 + steps: + - uses: actions/download-artifact@v4 + with: + name: files-ex${{ matrix.version }} + - name: List compiled files + run: find . -name '*.ex?' -type f -print + - if: ${{ env.TEST_SKIP != true && env.TEST_SKIP != 'true' }} + name: Run ${{ matrix.test }} + uses: fx31337/mql-tester-action@master + with: + Login: ${{ secrets.MT5_LOGIN }} + Password: ${{ secrets.MT5_PASSWORD }} + Server: MetaQuotes-Demo + TestDeposit: 2000 + TestExpert: ${{ matrix.test }} + TestFromDate: ${{ matrix.year }}.01.01 + TestPeriod: M1 + TestSymbol: EURUSD + TestToDate: ${{ matrix.year }}.01.14 + # yamllint disable-line rule:line-length + UrlExpert: file://${{ github.workspace }}/${{ env.TEST_PATH }}/${{ matrix.test }}.ex${{ matrix.version }} + Version: 5 + - if: ${{ failure() && runner.debug == '1' }} + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 20 + + cleanup: + name: Clean-up + needs: [compile] + uses: ./.github/workflows/cleanup.yml diff --git a/Platform/Backtest.h b/Platform/Backtest/Backtest.h similarity index 98% rename from Platform/Backtest.h rename to Platform/Backtest/Backtest.h index e19567798..c9ed6503e 100644 --- a/Platform/Backtest.h +++ b/Platform/Backtest/Backtest.h @@ -31,7 +31,7 @@ #endif // Includes. -#include "../EA.mqh" +#include "../../EA.mqh" class Backtest { protected: diff --git a/Platform/tests/Backtest.test.cpp b/Platform/Backtest/tests/Backtest.test.cpp similarity index 100% rename from Platform/tests/Backtest.test.cpp rename to Platform/Backtest/tests/Backtest.test.cpp diff --git a/Platform/tests/Backtest.test.mq4 b/Platform/Backtest/tests/Backtest.test.mq4 similarity index 100% rename from Platform/tests/Backtest.test.mq4 rename to Platform/Backtest/tests/Backtest.test.mq4 diff --git a/Platform/tests/Backtest.test.mq5 b/Platform/Backtest/tests/Backtest.test.mq5 similarity index 98% rename from Platform/tests/Backtest.test.mq5 rename to Platform/Backtest/tests/Backtest.test.mq5 index 170d97c70..22d53b558 100644 --- a/Platform/tests/Backtest.test.mq5 +++ b/Platform/Backtest/tests/Backtest.test.mq5 @@ -25,7 +25,7 @@ */ // Includes. -#include "../../Test.mqh" +#include "../../../Test.mqh" #include "../Backtest.h" // Test Backtest. diff --git a/Platform/Backtest/tests/Makefile b/Platform/Backtest/tests/Makefile new file mode 100644 index 000000000..e792364f0 --- /dev/null +++ b/Platform/Backtest/tests/Makefile @@ -0,0 +1,12 @@ +CC := g++ # C++ compiler +CFLAGS := -Wall -Wextra -std=c++17 -w # Compiler flags +SRCS := $(wildcard *.cpp) # Get all .cpp files in the current directory +OBJS := $(SRCS:.cpp=.o) # Object files corresponding to the source files + +all: $(OBJS) + +%.o: %.cpp + $(CC) $(CFLAGS) -c $< -o $@ + +clean: + rm -v $(OBJS) diff --git a/tests/CompileTest.mq5 b/tests/CompileTest.mq5 index 6cc33363b..bfa819eb3 100644 --- a/tests/CompileTest.mq5 +++ b/tests/CompileTest.mq5 @@ -46,6 +46,7 @@ struct IndicatorParams; #include "../Storage/Dict/Buffer/Buffer.h" #include "../Storage/Dict/Buffer/BufferFXT.h" #include "../Storage/Dict/Buffer/BufferStruct.h" +#include "../Platform/Backtest/Backtest.h" #include "../Platform/Chart/Chart.h" #include "../Config.mqh" #include "../Convert.mqh"