Test the SCons PreProcessor patch functionality
()
| 30 | sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) |
| 31 | |
| 32 | def test_preprocessor_patch(): |
| 33 | """Test the SCons PreProcessor patch functionality""" |
| 34 | try: |
| 35 | from scons_preprocessor_patch import SConsPreProcessorPatch, create_preprocessor_instance |
| 36 | |
| 37 | print("Testing SCons PreProcessor patch...") |
| 38 | |
| 39 | # Test creating patch instance |
| 40 | patch = SConsPreProcessorPatch() |
| 41 | print("✓ SConsPreProcessorPatch instance created successfully") |
| 42 | |
| 43 | # Test getting patched preprocessor |
| 44 | patched_class = patch.get_patched_preprocessor() |
| 45 | print("✓ Patched PreProcessor class retrieved successfully") |
| 46 | |
| 47 | # Test creating preprocessor instance |
| 48 | preprocessor = create_preprocessor_instance() |
| 49 | print("✓ PreProcessor instance created successfully") |
| 50 | |
| 51 | # Test basic functionality |
| 52 | test_content = """ |
| 53 | #define TEST_MACRO 1 |
| 54 | #ifdef TEST_MACRO |
| 55 | #define ENABLED_FEATURE 1 |
| 56 | #else |
| 57 | #define DISABLED_FEATURE 1 |
| 58 | #endif |
| 59 | """ |
| 60 | |
| 61 | preprocessor.process_contents(test_content) |
| 62 | namespace = preprocessor.cpp_namespace |
| 63 | |
| 64 | print("✓ PreProcessor processed test content successfully") |
| 65 | print(f" - TEST_MACRO: {namespace.get('TEST_MACRO', 'Not found')}") |
| 66 | print(f" - ENABLED_FEATURE: {namespace.get('ENABLED_FEATURE', 'Not found')}") |
| 67 | print(f" - DISABLED_FEATURE: {namespace.get('DISABLED_FEATURE', 'Not found')}") |
| 68 | |
| 69 | print("\n✓ All tests passed! SCons PreProcessor patch is working correctly.") |
| 70 | return True |
| 71 | |
| 72 | except ImportError as e: |
| 73 | print(f"✗ Import error: {e}") |
| 74 | print("Make sure SCons is available in the environment") |
| 75 | return False |
| 76 | except Exception as e: |
| 77 | print(f"✗ Test failed: {e}") |
| 78 | return False |
| 79 | |
| 80 | def test_building_integration(): |
| 81 | """Test integration with building.py""" |
no test coverage detected