Skip to content
Merged
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

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ target 'Runner' do
use_modular_headers!

flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))

target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33A341DA291ED36900D34E0F"
BuildableName = "RunnerTests.xctest"
BlueprintName = "RunnerTests"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import XCTest
@testable import test_plugin

class MyApi: AllVoidHostApi {
func doit() {}
}

// Since the generator is almost entirely shared with iOS, this is currently
// just testing that the generated code compiles for macOS (e.g., that the
// Flutter framework import is correct).
class BasicCompileTest: XCTestCase {
func testMakeApi() {
let api = MyApi()
XCTAssertNotNil(api)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# TODO(stuartmorgan): Remove this, so that review will show the effects of
# changes on generated files. This will need a way to avoid unnecessary churn,
# such as a flag to suppress version stamp generation.
*.gen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@
import Cocoa
import FlutterMacOS

/**
* This plugin is currently a no-op since only unit tests have been set up.
* In the future, this will register Pigeon APIs used in integration tests.
*/
public class TestPlugin: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "test_plugin", binaryMessenger: registrar.messenger)
let instance = TestPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}

public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "getPlatformVersion":
result("macOS " + ProcessInfo.processInfo.operatingSystemVersionString)
default:
result(FlutterMethodNotImplemented)
}
result(FlutterMethodNotImplemented)
}
}
71 changes: 42 additions & 29 deletions packages/pigeon/tool/run_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,7 @@
///
/// usage: dart run tool/run_tests.dart
////////////////////////////////////////////////////////////////////////////////
import 'dart:io'
show
Directory,
File,
Platform,
Process,
ProcessResult,
exit,
stderr,
stdout;
import 'dart:io' show File, Platform, Process, exit, stderr, stdout;
import 'dart:math';

import 'package:args/args.dart';
Expand All @@ -27,6 +18,8 @@ import 'package:meta/meta.dart';
const String _testFlag = 'test';
const String _listFlag = 'list';

const String testPluginRelativePath = 'platform_tests/test_plugin';

@immutable
class _TestInfo {
const _TestInfo({required this.function, this.description});
Expand Down Expand Up @@ -276,28 +269,48 @@ Future<int> _runIosUnitTests() async {
}

Future<int> _runMacOSSwiftUnitTests() async {
const String macosSwiftUnitTestsPath =
'./platform_tests/macos_swift_unit_tests';
final int generateCode = await _runPigeon(
input: '$macosSwiftUnitTestsPath/pigeons/messages.dart',
iosSwiftOut: '$macosSwiftUnitTestsPath/macos/Classes/messages.g.swift',
);
if (generateCode != 0) {
return generateCode;
}
final Directory oldCwd = Directory.current;
try {
Directory.current = Directory('$macosSwiftUnitTestsPath/macos');
final ProcessResult lintResult =
Process.runSync('pod', <String>['lib', 'lint']);
if (lintResult.exitCode != 0) {
return lintResult.exitCode;
const String macosSwiftUnitTestsPath = './$testPluginRelativePath';
const List<String> tests = <String>[
'all_void',
];
int generateCode = 0;

for (final String test in tests) {
generateCode = await _runPigeon(
input: './pigeons/$test.dart',
iosSwiftOut:
'$macosSwiftUnitTestsPath/macos/Classes/${snakeToPascalCase(test)}.gen.swift',
);
if (generateCode != 0) {
return generateCode;
}
} finally {
Directory.current = oldCwd;
}

return 0;
const String examplePath = '$macosSwiftUnitTestsPath/example';
final Process compile = await _streamOutput(Process.start(
'flutter',
<String>['build', 'macos'],
workingDirectory: examplePath,
runInShell: true,
));
final int compileCode = await compile.exitCode;
if (compileCode != 0) {
return compileCode;
}

final Process run = await _streamOutput(Process.start(
'xcodebuild',
<String>[
'-workspace',
'Runner.xcworkspace',
'-scheme',
'Runner',
'test',
],
workingDirectory: '$examplePath/macos',
));

return run.exitCode;
}

Future<int> _runIosSwiftUnitTests() async {
Expand Down