diff --git a/pkgs/native_toolchain_c/CHANGELOG.md b/pkgs/native_toolchain_c/CHANGELOG.md index c5327dc251..b07fb21c71 100644 --- a/pkgs/native_toolchain_c/CHANGELOG.md +++ b/pkgs/native_toolchain_c/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.17.1-wip + +* Skip Rust test when no toolchain is installed. + ## 0.17.0 * Fix treeshaking on mac. diff --git a/pkgs/native_toolchain_c/pubspec.yaml b/pkgs/native_toolchain_c/pubspec.yaml index 54de4073e1..e4d038d0d9 100644 --- a/pkgs/native_toolchain_c/pubspec.yaml +++ b/pkgs/native_toolchain_c/pubspec.yaml @@ -1,7 +1,7 @@ name: native_toolchain_c description: >- A library to invoke the native C compiler installed on the host machine. -version: 0.17.0 +version: 0.17.1-wip repository: https://github.com/dart-lang/native/tree/main/pkgs/native_toolchain_c topics: diff --git a/pkgs/native_toolchain_c/test/clinker/rust_test.dart b/pkgs/native_toolchain_c/test/clinker/rust_test.dart index 2223106eb4..cc1e8441fc 100644 --- a/pkgs/native_toolchain_c/test/clinker/rust_test.dart +++ b/pkgs/native_toolchain_c/test/clinker/rust_test.dart @@ -17,45 +17,48 @@ Future main() async { final linkOutputBuilder = LinkOutputBuilder(); final targetArchitecture = Architecture.current; final targetOS = OS.current; - late final bool rustToolchainInstalled; + late var rustToolchainInstalled = false; setUpAll(() async { final tempUri = await tempDirForTest(); final tempUri2 = await tempDirForTest(); staticLib = tempUri.resolve(targetOS.staticlibFileName('libtest')); - final processResult = await Process.run('rustc', [ - '--crate-type=staticlib', - 'test/clinker/testfiles/linker/test.rs', - '-o', - staticLib.toFilePath(), - ]); - rustToolchainInstalled = processResult.exitCode == 0; + try { + final processResult = await Process.run('rustc', [ + '--crate-type=staticlib', + 'test/clinker/testfiles/linker/test.rs', + '-o', + staticLib.toFilePath(), + ]); + rustToolchainInstalled = processResult.exitCode == 0; + } catch (e, s) { + print('$e'); + print('$s'); + } if (rustToolchainInstalled) { await File.fromUri( staticLib, ).copy(tempUri.resolve('libtest.a').toFilePath()); - } - final linkInputBuilder = LinkInputBuilder() - ..setupShared( - packageName: 'testpackage', - packageRoot: tempUri, - outputFile: tempUri.resolve('output.json'), - outputDirectoryShared: tempUri2, - ) - ..setupLink(assets: [], recordedUsesFile: null) - ..addExtension( - CodeAssetExtension( - targetOS: targetOS, - targetArchitecture: targetArchitecture, - linkModePreference: LinkModePreference.dynamic, - ), - ); + } else { + final linkInputBuilder = LinkInputBuilder() + ..setupShared( + packageName: 'testpackage', + packageRoot: tempUri, + outputFile: tempUri.resolve('output.json'), + outputDirectoryShared: tempUri2, + ) + ..setupLink(assets: [], recordedUsesFile: null) + ..addExtension( + CodeAssetExtension( + targetOS: targetOS, + targetArchitecture: targetArchitecture, + linkModePreference: LinkModePreference.dynamic, + ), + ); - linkInput = linkInputBuilder.build(); + linkInput = linkInputBuilder.build(); + } }); test('link rust binary with script treeshakes', () async { - if (!rustToolchainInstalled) { - return; - } final treeshakeOption = LinkerOptions.treeshake( symbolsToKeep: ['my_other_func'], ); @@ -72,12 +75,9 @@ Future main() async { : false; expect(symbols, contains('my_other_func'), skip: skipReason); expect(symbols, isNot(contains('my_func')), skip: skipReason); - }); + }, skip: !rustToolchainInstalled); test('link rust binary without script keeps symbols', () async { - if (!rustToolchainInstalled) { - return; - } final manualOption = LinkerOptions.manual( symbolsToKeep: ['my_other_func'], stripDebug: true, @@ -96,7 +96,7 @@ Future main() async { : false; expect(symbols, contains('my_other_func'), skip: skipReason); expect(symbols, contains('my_func'), skip: skipReason); - }); + }, skip: !rustToolchainInstalled); } Future _link(