|
| 1 | +#!/usr/bin/env ruby |
| 2 | +# Script to add new test files to the SwiftDataTablesTests target |
| 3 | +# Usage: ruby scripts/add_test_files.rb |
| 4 | + |
| 5 | +require 'xcodeproj' |
| 6 | + |
| 7 | +project_path = File.expand_path('../Example/SwiftDataTables.xcodeproj', __dir__) |
| 8 | +project = Xcodeproj::Project.open(project_path) |
| 9 | + |
| 10 | +# Find the SwiftDataTablesTests target |
| 11 | +test_target = project.targets.find { |t| t.name == 'SwiftDataTablesTests' } |
| 12 | + |
| 13 | +unless test_target |
| 14 | + puts "Error: Could not find SwiftDataTablesTests target" |
| 15 | + exit 1 |
| 16 | +end |
| 17 | + |
| 18 | +# Find the SwiftDataTablesTests group |
| 19 | +test_group = project.main_group.find_subpath('SwiftDataTablesTests', false) |
| 20 | + |
| 21 | +unless test_group |
| 22 | + puts "Error: Could not find SwiftDataTablesTests group" |
| 23 | + exit 1 |
| 24 | +end |
| 25 | + |
| 26 | +# New test files to add |
| 27 | +new_test_files = [ |
| 28 | + 'DataTableValueTypeTests.swift', |
| 29 | + 'DataTableSortTypeTests.swift', |
| 30 | + 'DataTableConfigurationTests.swift', |
| 31 | + 'DataTableFixedColumnTypeTests.swift', |
| 32 | + 'DataHeaderFooterViewModelTests.swift' |
| 33 | +] |
| 34 | + |
| 35 | +# Get existing file references in the group |
| 36 | +existing_files = test_group.files.map(&:display_name) |
| 37 | + |
| 38 | +# Add each new file |
| 39 | +new_test_files.each do |filename| |
| 40 | + if existing_files.include?(filename) |
| 41 | + puts "Skipping #{filename} - already in project" |
| 42 | + next |
| 43 | + end |
| 44 | + |
| 45 | + file_path = File.expand_path("../Example/SwiftDataTablesTests/#{filename}", __dir__) |
| 46 | + |
| 47 | + unless File.exist?(file_path) |
| 48 | + puts "Warning: #{filename} does not exist at #{file_path}" |
| 49 | + next |
| 50 | + end |
| 51 | + |
| 52 | + # Add file reference to group |
| 53 | + file_ref = test_group.new_file(file_path) |
| 54 | + |
| 55 | + # Add to target's compile sources |
| 56 | + test_target.source_build_phase.add_file_reference(file_ref) |
| 57 | + |
| 58 | + puts "Added #{filename} to SwiftDataTablesTests target" |
| 59 | +end |
| 60 | + |
| 61 | +# Save the project |
| 62 | +project.save |
| 63 | + |
| 64 | +puts "Done! Project saved." |
0 commit comments