1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "test/utils/test_list.h"
17
18 #include "test/utils/test_util.h"
19
20 // testcase list
21 #include "test/testcases/js_breakpoint_test.h"
22 #include "test/testcases/js_breakpoint_arrow_test.h"
23 #include "test/testcases/js_breakpoint_async_test.h"
24 #include "test/testcases/js_exception_test.h"
25 #include "test/testcases/js_range_error_test.h"
26 #include "test/testcases/js_single_step_test.h"
27 #include "test/testcases/js_step_into_test.h"
28 #include "test/testcases/js_step_over_test.h"
29 #include "test/testcases/js_step_out_test.h"
30 #include "test/testcases/js_syntax_exception_test.h"
31 #include "test/testcases/js_throw_exception_test.h"
32
33 namespace panda::ecmascript::tooling::test {
34 static std::string g_currentTestName = "";
35
RegisterTests()36 static void RegisterTests()
37 {
38 // Register testcases
39 TestUtil::RegisterTest("JsExceptionTest", GetJsExceptionTest());
40 TestUtil::RegisterTest("JsSingleStepTest", GetJsSingleStepTest());
41 TestUtil::RegisterTest("JsBreakpointTest", GetJsBreakpointTest());
42 TestUtil::RegisterTest("JsBreakpointAsyncTest", GetJsBreakpointAsyncTest());
43 TestUtil::RegisterTest("JsBreakpointArrowTest", GetJsBreakpointArrowTest());
44 TestUtil::RegisterTest("JsRangeErrorTest", GetJsRangeErrorTest());
45 TestUtil::RegisterTest("JsSyntaxExceptionTest", GetJsSyntaxExceptionTest());
46 TestUtil::RegisterTest("JsThrowExceptionTest", GetJsThrowExceptionTest());
47 TestUtil::RegisterTest("JsStepIntoTest", GetJsStepIntoTest());
48 TestUtil::RegisterTest("JsStepOverTest", GetJsStepOverTest());
49 TestUtil::RegisterTest("JsStepOutTest", GetJsStepOutTest());
50 }
51
GetTestList()52 std::vector<const char *> GetTestList()
53 {
54 RegisterTests();
55 std::vector<const char *> res;
56
57 auto &tests = TestUtil::GetTests();
58 for (const auto &entry : tests) {
59 res.push_back(entry.first.c_str());
60 }
61 return res;
62 }
63
SetCurrentTestName(const std::string & testName)64 void SetCurrentTestName(const std::string &testName)
65 {
66 g_currentTestName = testName;
67 }
68
GetCurrentTestName()69 std::string GetCurrentTestName()
70 {
71 return g_currentTestName;
72 }
73
GetTestEntryPoint(const std::string & testName)74 std::pair<std::string, std::string> GetTestEntryPoint(const std::string &testName)
75 {
76 return TestUtil::GetTest(testName)->GetEntryPoint();
77 }
78 } // namespace panda::ecmascript::tooling::test
79