|
54 | 54 | end
|
55 | 55 |
|
56 | 56 | context 'Linter' do
|
| 57 | + def run_l10n_linter_test(data_file) |
| 58 | + # Arrange: Prepare test files |
| 59 | + test_file = File.join(File.dirname(__FILE__), 'test-data', 'translations', "test-lint-ios-#{data_file}.yaml") |
| 60 | + yml = YAML.load_file(test_file) |
| 61 | + |
| 62 | + files = yml['test_data'] |
| 63 | + FileUtils.mkdir_p(@test_data_dir) |
| 64 | + files.each do |lang, content| |
| 65 | + lproj = File.join(@test_data_dir, "#{lang}.lproj") |
| 66 | + FileUtils.mkdir_p(lproj) |
| 67 | + File.write(File.join(lproj, 'Localizable.strings'), content) unless content.nil? |
| 68 | + end |
| 69 | + |
| 70 | + # Act |
| 71 | + # Note: We will install SwiftGen in vendor/swiftgen if it's not already installed yet, and intentionally won't |
| 72 | + # remove this after the test ends, so that further executions of the test run faster. |
| 73 | + # Only the first execution of the tests might take longer if it needs to install SwiftGen first to be able to run the tests. |
| 74 | + install_dir = "vendor/swiftgen/#{Fastlane::Helper::Ios::L10nLinterHelper::SWIFTGEN_VERSION}" |
| 75 | + result = run_described_fastlane_action( |
| 76 | + install_path: install_dir, |
| 77 | + input_dir: @test_data_dir, |
| 78 | + base_lang: 'en' |
| 79 | + ) |
| 80 | + |
| 81 | + # Assert |
| 82 | + expect(result).to eq(yml['result']) |
| 83 | + end |
| 84 | + |
57 | 85 | before(:each) do
|
58 | 86 | @test_data_dir = Dir.mktmpdir('a8c-lint-l10n-tests-data-')
|
59 | 87 | allow(FastlaneCore::UI).to receive(:abort_with_message!)
|
|
84 | 112 | end
|
85 | 113 | end
|
86 | 114 | end
|
87 |
| - |
88 |
| -def run_l10n_linter_test(data_file) |
89 |
| - # Arrange: Prepare test files |
90 |
| - test_file = File.join(File.dirname(__FILE__), 'test-data', 'translations', "test-lint-ios-#{data_file}.yaml") |
91 |
| - yml = YAML.load_file(test_file) |
92 |
| - |
93 |
| - files = yml['test_data'] |
94 |
| - FileUtils.mkdir_p(@test_data_dir) |
95 |
| - files.each do |lang, content| |
96 |
| - lproj = File.join(@test_data_dir, "#{lang}.lproj") |
97 |
| - FileUtils.mkdir_p(lproj) |
98 |
| - File.write(File.join(lproj, 'Localizable.strings'), content) unless content.nil? |
99 |
| - end |
100 |
| - |
101 |
| - # Act |
102 |
| - # Note: We will install SwiftGen in vendor/swiftgen if it's not already installed yet, and intentionally won't |
103 |
| - # remove this after the test ends, so that further executions of the test run faster. |
104 |
| - # Only the first execution of the tests might take longer if it needs to install SwiftGen first to be able to run the tests. |
105 |
| - install_dir = "vendor/swiftgen/#{Fastlane::Helper::Ios::L10nLinterHelper::SWIFTGEN_VERSION}" |
106 |
| - result = run_described_fastlane_action( |
107 |
| - install_path: install_dir, |
108 |
| - input_dir: @test_data_dir, |
109 |
| - base_lang: 'en' |
110 |
| - ) |
111 |
| - |
112 |
| - # Assert |
113 |
| - expect(result).to eq(yml['result']) |
114 |
| -end |
0 commit comments