diff --git a/lib/fastlane/plugin/flutter/actions/flutter_generate_action.rb b/lib/fastlane/plugin/flutter/actions/flutter_generate_action.rb index ca0f0d0..8ab7d50 100644 --- a/lib/fastlane/plugin/flutter/actions/flutter_generate_action.rb +++ b/lib/fastlane/plugin/flutter/actions/flutter_generate_action.rb @@ -42,16 +42,6 @@ def self.run(params) if params[:coverage_all_imports] UI.message("Generating #{ALL_IMPORTS_TEST_FILE} for coverage...") - dart_file_literals = Dir['lib/**/*.dart'].reject do |file_name| - # ".g.dart" files often are "part of" files and can not be imported - # directly. Commonly coverage for generated files is not that useful - file_name.end_with?('.g.dart') - end.map do |file_name| - Helper::FlutterHelper. - import_path_for_test(file_name, '..'). - gsub("'", "\\\\'") - end - File.write( ALL_IMPORTS_TEST_FILE, <<-DART @@ -60,12 +50,11 @@ def self.run(params) // of overall project is calculated correctly. Do not modify this // file manually! -// ignore_for_file: unused_import, directives_ordering -// ignore_for_file: avoid_relative_lib_imports -// ignore_for_file: lines_longer_than_80_chars - -#{dart_file_literals.map { |fn| "import '#{fn}';" }.sort.join("\n")} +// https://github.com/flutter/flutter/issues/27997#issuecomment-1644224366 +// ignore: unused_import +import 'package:#{Helper::FlutterHelper.pub_package_name}/main.dart'; +// Fake test in order to make each file reachable by the coverage void main() {} DART ) diff --git a/lib/fastlane/plugin/flutter/helper/flutter_helper.rb b/lib/fastlane/plugin/flutter/helper/flutter_helper.rb index 4277c4c..ca73b7d 100644 --- a/lib/fastlane/plugin/flutter/helper/flutter_helper.rb +++ b/lib/fastlane/plugin/flutter/helper/flutter_helper.rb @@ -64,26 +64,6 @@ def self.pub_package_name YAML.load_file('pubspec.yaml')['name'] end - def self.import_path_for_test(file_to_import, relative_path) - unless file_to_import.start_with?('lib/') - return File.join(relative_path, file_to_import) - end - - # Import file schema in tests have to match files in lib/ exactly. From - # Dart perspective, symbols in files imported via relative and - # "package:" file paths are different symbols. - package_specification = "package:#{pub_package_name}/" - if File.read(file_to_import, 4096).include?(package_specification) - # If there's a package reference in the first few bytes of the file, - # chances are, it's using "package:..." imports. Indeed, checking the - # file itself isn't sufficient to explore all of its dependencies, but - # we expect imports to be consistent in the project. - "#{package_specification}#{file_to_import['lib/'.size..-1]}" - else - File.join(relative_path, file_to_import) - end - end - def self.execute(*command) # TODO(dotdoom): make CommandExecutor (and Actions.sh) behave similarly. command = command.shelljoin