import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; void main() { test('native build refuses only its running executable', () async { final root = await Directory.systemTemp.createTemp('cutdex build guard '); addTearDown(() => root.delete(recursive: true)); final executable = await File('/bin/sleep').copy('${root.path}/cutdex'); await Process.run('/bin/chmod', ['u+x', executable.path]); Future check(String path) => Process.run('/bin/sh', [ 'tool/macos/check_macos_build_target.sh', path, ]); expect((await check(executable.path)).exitCode, 0); final process = await Process.start(executable.path, ['60']); try { final blocked = await check(executable.path); expect(blocked.exitCode, 1); expect(blocked.stderr, contains('Save your edits')); expect((await check('${root.path}/other/cutdex')).exitCode, 0); } finally { process.kill(); await process.exitCode; } expect((await check(executable.path)).exitCode, 0); }, skip: !Platform.isMacOS); }