1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Test script to verify the refactoring is successful
import sys
import os
# Add current directory to path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
# Mock rtconfig module for testing
import mock_rtconfig
sys.modules['rtconfig'] = mock_rtconfig
def test_targets_import():
"""Test if all target modules can be imported successfully"""
print("Testing targets module imports...")
try:
# Test importing targets module
import targets
print("✓ targets module imported successfully")
# Test importing individual target modules
target_modules = [
'keil', 'iar', 'vs', 'vs2012', 'codeblocks', 'ua',
'vsc', 'cdk', 'ses', 'eclipse', 'codelite',
'cmake', 'xmake', 'esp_idf', 'zigbuild', 'makefile', 'rt_studio'
]
for module_name in target_modules:
try:
module = getattr(targets, module_name)
print(f"✓ {module_name} module imported successfully")
except AttributeError as e:
print(f"✗ Failed to import {module_name}: {e}")
return False
return True
except ImportError as e:
print(f"✗ Failed to import targets module: {e}")
return False
def test_building_import():
"""Test if building.py can import target modules"""
print("\nTesting building.py imports...")
try:
# Test importing building module
import building
print("✓ building module imported successfully")
# Test if GenTargetProject function exists
if hasattr(building, 'GenTargetProject'):
print("✓ GenTargetProject function found")
else:
print("✗ GenTargetProject function not found")
return False
return True
except ImportError as e:
print(f"✗ Failed to import building module: {e}")
return False
def test_target_functions():
"""Test if target functions can be called"""
print("\nTesting target function calls...")
try:
# Test importing specific target functions
from targets.keil import MDK4Project, MDK5Project
print("✓ Keil target functions imported successfully")
from targets.iar import IARProject
print("✓ IAR target functions imported successfully")
from targets.eclipse import TargetEclipse
print("✓ Eclipse target functions imported successfully")
from targets.cmake import CMakeProject
print("✓ CMake target functions imported successfully")
import targets.rt_studio
print("✓ RT-Studio target functions imported successfully")
return True
except ImportError as e:
print(f"✗ Failed to import target functions: {e}")
return False
def main():
"""Main test function"""
print("RT-Thread Tools Refactoring Test")
print("=" * 40)
success = True
# Run all tests
if not test_targets_import():
success = False
if not test_building_import():
success = False
if not test_target_functions():
success = False
print("\n" + "=" * 40)
if success:
print("✓ All tests passed! Refactoring is successful.")
return 0
else:
print("✗ Some tests failed. Please check the errors above.")
return 1
if __name__ == '__main__':
sys.exit(main())
|