Skip to content

Commit a8ce9ee

Browse files
committed
Skip tests when no rust is installed
1 parent 5032e20 commit a8ce9ee

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pkgs/native_toolchain_c/test/clinker/rust_test.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@ Future<void> main() async {
1717
final linkOutputBuilder = LinkOutputBuilder();
1818
final targetArchitecture = Architecture.current;
1919
final targetOS = OS.current;
20+
late final bool rustToolchainInstalled;
2021
setUpAll(() async {
2122
final tempUri = await tempDirForTest();
2223
final tempUri2 = await tempDirForTest();
2324
staticLib = tempUri.resolve(targetOS.staticlibFileName('libtest'));
24-
await Process.run('rustc', [
25+
final processResult = await Process.run('rustc', [
2526
'--crate-type=staticlib',
2627
'test/clinker/testfiles/linker/test.rs',
2728
'-o',
2829
staticLib.toFilePath(),
2930
]);
31+
rustToolchainInstalled = processResult.exitCode == 0;
3032
final linkInputBuilder = LinkInputBuilder()
3133
..setupShared(
3234
packageName: 'testpackage',
@@ -50,6 +52,9 @@ Future<void> main() async {
5052
).copy(tempUri.resolve('libtest.a').toFilePath());
5153
});
5254
test('link rust binary with script treeshakes', () async {
55+
if (!rustToolchainInstalled) {
56+
return;
57+
}
5358
final treeshakeOption = LinkerOptions.treeshake(
5459
symbolsToKeep: ['my_other_func'],
5560
);
@@ -69,6 +74,9 @@ Future<void> main() async {
6974
});
7075

7176
test('link rust binary without script keeps symbols', () async {
77+
if (!rustToolchainInstalled) {
78+
return;
79+
}
7280
final manualOption = LinkerOptions.manual(
7381
symbolsToKeep: ['my_other_func'],
7482
stripDebug: true,
@@ -110,6 +118,5 @@ Future<String?> _link(
110118

111119
await expectMachineArchitecture(asset.file!, targetArchitecture, targetOS);
112120

113-
final symbols = await readSymbols(asset, targetOS);
114-
return symbols;
121+
return await readSymbols(asset, targetOS);
115122
}

0 commit comments

Comments
 (0)