diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7a89259 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + schedule: + - cron: '00 01 */4 * *' + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest] + steps: + - uses: actions/checkout@v2 + - name: Install Qt + uses: jurplel/install-qt-action@v2 + - name: Check infrastructure + run: | + qmake --version + nproc --all + echo "Done" + shell: bash + - name: Build and test (ubuntu) + if: matrix.os == 'ubuntu-latest' + run: | + set -e + sudo apt-get install xvfb + cd $GITHUB_WORKSPACE + cd tests/testableunittests/ + qmake + make -j `nproc --all` + xvfb-run --auto-servernum ./testableunittests + cd ../../tests/testablecmdtests + qmake + make -j `nproc --all` + ./run-tests.sh + shell: bash diff --git a/automator.cpp b/automator.cpp index 5ec980b..1a8bd18 100644 --- a/automator.cpp +++ b/automator.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include "automator.h" @@ -151,7 +151,7 @@ QObjectList Automator::findObjects(QString objectName) bool Automator::waitExists(QString objectName, int timeout) { - QTime time; + QElapsedTimer time; time.start(); while (true) { @@ -174,7 +174,7 @@ bool Automator::waitExists(QString objectName, int timeout) bool Automator::waitUntil(QObject *object, QString property, QVariant value, int timeout) { QVariant objectValue = object->property(property.toLocal8Bit().constData()); - QTime time; + QElapsedTimer time; time.start(); while (objectValue != value) { @@ -213,7 +213,7 @@ bool Automator::waitUntilSignal(QObject *object, const char *signal, int timeout bool Automator::waitUntil(QString objectName, QString property, QVariant value, int timeout) { - QTime time; + QElapsedTimer time; time.start(); QObject* object = findObject(objectName); diff --git a/automator.h b/automator.h index f7ba275..65d5522 100644 --- a/automator.h +++ b/automator.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include /// Automator provides an interface to manipulate UI object loaded by QQmlApplicationEngine @@ -51,7 +51,7 @@ class Automator : public QObject template bool waitUntil(Functor functor, int timeout = -1) { - QTime time; + QElapsedTimer time; time.start(); while (!functor()) { diff --git a/tests/testablecmdtests/run-tests.sh b/tests/testablecmdtests/run-tests.sh index 4b3233c..123800e 100755 --- a/tests/testablecmdtests/run-tests.sh +++ b/tests/testablecmdtests/run-tests.sh @@ -13,7 +13,7 @@ OUTPUT="default" fi echo "testable $ARG" -./testablecmdtests $ARG | grep Totals > $OUTPUT.out 2>&1 +xvfb-run --auto-servernum ./testablecmdtests $ARG | grep Totals | sed 's/, [[:digit:]]\+ms//g' > $OUTPUT.out 2>&1 diff -uN $SRCDIR/$OUTPUT.expected $OUTPUT.out } diff --git a/tests/testableunittests/testableunittests.cpp b/tests/testableunittests/testableunittests.cpp index 4b481aa..ff78051 100644 --- a/tests/testableunittests/testableunittests.cpp +++ b/tests/testableunittests/testableunittests.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include "testableunittests.h" @@ -61,7 +62,7 @@ void TestableUnitTests::automatorObtainSingletonObject() void TestableUnitTests::automatorWaitUntilSignal() { QTimer * timer = new QTimer(this); - QTime time; + QElapsedTimer time; time.start(); timer->setInterval(500);