1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the V4VM module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28#ifndef TEST262RUNNER_H
29#define TEST262RUNNER_H
30#include <qstring.h>
31#include <qstringlist.h>
32#include <qset.h>
33#include <qmap.h>
34#include <qmutex.h>
35#include <qthreadpool.h>
36
37struct TestCase {
38 TestCase() = default;
39 TestCase(const QString &test)
40 : test(test) {}
41 enum Result {
42 Skipped,
43 Passes,
44 Fails,
45 Crashes
46 };
47 bool skipTestCase = false;
48 Result strictExpectation = Passes;
49 Result sloppyExpectation = Passes;
50 Result strictResult = Skipped;
51 Result sloppyResult = Skipped;
52
53 QString test;
54};
55
56struct TestData : TestCase {
57 TestData(const TestCase &testCase)
58 : TestCase(testCase) {}
59 // flags
60 bool negative = false;
61 bool runInStrictMode = true;
62 bool runInSloppyMode = true;
63 bool runAsModuleCode = false;
64 bool async = false;
65
66 bool isExcluded = false;
67
68 QList<QByteArray> includes;
69
70 QByteArray harness;
71 QByteArray content;
72};
73
74class Test262Runner
75{
76public:
77 Test262Runner(const QString &command, const QString &testDir);
78 ~Test262Runner();
79
80 enum Mode {
81 Sloppy = 0,
82 Strict = 1
83 };
84
85 enum Flags {
86 Verbose = 0x1,
87 Parallel = 0x2,
88 ForceBytecode = 0x4,
89 ForceJIT = 0x8,
90 WithTestExpectations = 0x10,
91 UpdateTestExpectations = 0x20,
92 WriteTestExpectations = 0x40,
93 };
94 void setFlags(int f) { flags = f; }
95
96 void setFilter(const QString &f) { filter = f; }
97
98 void cat();
99 bool run();
100
101 bool report();
102
103private:
104 friend class SingleTest;
105 bool loadTests();
106 void loadTestExpectations();
107 void updateTestExpectations();
108 void writeTestExpectations();
109 int runSingleTest(TestCase testCase);
110
111 TestData getTestData(const TestCase &testCase);
112 void parseYaml(const QByteArray &content, TestData *data);
113
114 QByteArray harness(const QByteArray &name);
115
116 void addResult(TestCase result);
117
118 QString command;
119 QString testDir;
120 int flags = 0;
121
122 QMutex mutex;
123 QString filter;
124
125 QMap<QString, TestCase> testCases;
126 QHash<QByteArray, QByteArray> harnessFiles;
127
128 QThreadPool *threadPool = nullptr;
129};
130
131
132#endif
133

source code of qtdeclarative/tests/auto/qml/ecmascripttests/qjstest/test262runner.h