From d154917bd61e2653e5c19f5f3187f2579e92004f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Thu, 2 Dec 2021 09:38:57 +0100 Subject: [PATCH 1/4] Add missing import. --- ds-ext/source/ext.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ds-ext/source/ext.d b/ds-ext/source/ext.d index 81ec9df..4efb1e6 100644 --- a/ds-ext/source/ext.d +++ b/ds-ext/source/ext.d @@ -2,9 +2,9 @@ import dmdscript.program; import dmdscript.script; import dmdscript.extending; +import std.file; import std.stdio; import std.typecons; -import std.stdio; int func(int a,int b){ return a*b; } From 8e5c277e74e0e69c5cfa425b6abbc7e8808c7dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Thu, 2 Dec 2021 10:33:30 +0100 Subject: [PATCH 2/4] Replace Travis-CI by GitHub actions. --- .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 6 ---- run-test262.sh | 2 ++ 3 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7bc6fd0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,60 @@ +name: Test Suite + +# Only triggers on pushes/PRs to master +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + test: + name: CI + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest] + dc: [dmd-latest, ldc-latest, ldc-1.15.0] + arch: [x86, x86_64] + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + + - name: Install D compiler + uses: dlang-community/setup-dlang@v1 + with: + compiler: ${{ matrix.dc }} + + - name: Run tests + env: + CONFIG: ${{matrix.config}} + ARCH: ${{matrix.arch}} + shell: bash + run: dub test :engine + testsuite: + name: Test262 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + dc: [dmd-latest] + arch: [x86_64] + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + + - name: Install D compiler + uses: dlang-community/setup-dlang@v1 + with: + compiler: ${{ matrix.dc }} + + - name: Run tests + env: + CONFIG: ${{matrix.config}} + ARCH: ${{matrix.arch}} + shell: bash + run: ./run-test262.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2ab348e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: d -sudo: false - -script: - - ./build.sh - - ./run-test262.sh diff --git a/run-test262.sh b/run-test262.sh index 409fc3b..71f1aeb 100755 --- a/run-test262.sh +++ b/run-test262.sh @@ -1,6 +1,8 @@ #!/bin/bash set -e +./build.sh + if ! [ -d test262 ] ; then echo "Cloning test262 test suite..." git clone https://github.com/tc39/test262.git From 2fa9dc5161fd931b3b5ab9e14fc4fb9ead6d3af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Thu, 2 Dec 2021 15:07:22 +0100 Subject: [PATCH 3/4] Switch to a fixed version of the test suite to avoid externally broken tests. Since DMDScripts implements an old version of the ECMA standard, newer tests are currently mostly irrelevant for now. However, since we fail a lot of tests, it is important to have a known baseline in terms of which tests succeed. For now, this is only counting the number of passed tests as opposed to tracking each test case individually. --- run-test262.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/run-test262.sh b/run-test262.sh index 71f1aeb..95d6866 100755 --- a/run-test262.sh +++ b/run-test262.sh @@ -1,27 +1,33 @@ #!/bin/bash -set -e +set -xe ./build.sh if ! [ -d test262 ] ; then echo "Cloning test262 test suite..." git clone https://github.com/tc39/test262.git + cd test262 + git checkout a456b0a390bb0f70b4cb8d38cb5ab0ecb557a851 + cd .. echo "Applying patch to make the harness ES3/5 compatible..." sed 's/ let / var /g' -i test262/harness/assert.js fi if ! [ -d test262-harness-py ] ; then echo "Cloning the console test runner..." git clone https://github.com/test262-utils/test262-harness-py.git + cd test262-harness-py + git checkout 0f2acdd882c84cff43b9d60df7574a1901e2cdcd + cd .. echo "Applying patch to adjust the runner for the latest version of the test suite..." sed '/self\.suite\.GetInclude("cth\.js")/d' -i test262-harness-py/src/test262.py fi echo "Running the test suite..." cd test262-harness-py -src/test262.py --summary --non_strict_only --command ../timed-dmdscript.sh --tests=../test262 | tee ../dmdscript-test262.log | grep '=== .* failed in .* ===' +python2 src/test262.py --summary --non_strict_only --command ../timed-dmdscript.sh --tests=../test262 | tee ../dmdscript-test262.log | grep '=== .* failed in .* ===' cd .. -EXPECTED_TO_PASS=5238 +EXPECTED_TO_PASS=5223 PASSED=$(grep ' - Passed [0-9]* tests' dmdscript-test262.log | sed -n 's/.*Passed \([0-9]*\) tests.*/\1/;P') if [ "$PASSED" -gt "$EXPECTED_TO_PASS" ]; then From e6086022994dbea27c9ec88e1388113b7b75da9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Thu, 2 Dec 2021 15:55:24 +0100 Subject: [PATCH 4/4] Remove unused and broken OutBuffer.printf method. Crashes on Linux/LDC, probably due to an issue with the varargs implementation. Removing, since this isn't used anyway. --- engine/source/dmdscript/outbuffer.d | 65 +---------------------------- 1 file changed, 1 insertion(+), 64 deletions(-) diff --git a/engine/source/dmdscript/outbuffer.d b/engine/source/dmdscript/outbuffer.d index d52a810..3b26129 100644 --- a/engine/source/dmdscript/outbuffer.d +++ b/engine/source/dmdscript/outbuffer.d @@ -250,68 +250,6 @@ class OutBuffer return cast(string) data[0 .. offset].idup; } - /***************************************** - * Append output of C's vprintf() to internal buffer. - */ - - void vprintf(string format, va_list args) - { - char[128] buffer; - char* p; - uint psize; - int count; - - auto f = toStringz(format); - p = buffer.ptr; - psize = buffer.length; - for (;;) - { - version(Windows) - { - count = _vsnprintf(p,psize,f,args); - if (count != -1) - break; - psize *= 2; - p = cast(char *) alloca(psize); // buffer too small, try again with larger size - } - version(Posix) - { - count = vsnprintf(p,psize,f,args); - if (count == -1) - psize *= 2; - else if (count >= psize) - psize = count + 1; - else - break; - /+ - if (p != buffer) - c.stdlib.free(p); - p = (char *) c.stdlib.malloc(psize); // buffer too small, try again with larger size - +/ - p = cast(char *) alloca(psize); // buffer too small, try again with larger size - } - } - write(cast(ubyte[]) p[0 .. count]); - /+ - version (Posix) - { - if (p != buffer) - c.stdlib.free(p); - } - +/ - } - - /***************************************** - * Append output of C's printf() to internal buffer. - */ - - void printf(string format, ...) - { - va_list ap; - ap = cast(va_list)&format; - ap += format.sizeof; - vprintf(format, ap); - } /***************************************** * At offset index into buffer, create nbytes of space by shifting upwards @@ -349,7 +287,6 @@ unittest buf.write("hello"[]); buf.write(cast(byte)0x20); buf.write("world"[]); - buf.printf(" %d", 6); //printf("buf = '%.*s'\n", buf.toString()); - assert(cmp(buf.toString(), "hello world 6") == 0); + assert(cmp(buf.toString(), "hello world") == 0); }