Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions lib/fastlane/plugin/flutter/actions/flutter_generate_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
Expand Down
20 changes: 0 additions & 20 deletions lib/fastlane/plugin/flutter/helper/flutter_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down