• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

juancastillo0 / wasm_run / 6448410382

08 Oct 2023 03:12PM UTC coverage: 72.768% (+1.6%) from 71.197%
6448410382

Pull #14

github

juancastillo0
use flutter example assets for wasi and threads tests
Pull Request #14: Wit component generator package release

128 of 128 new or added lines in 9 files covered. (100.0%)

2103 of 2890 relevant lines covered (72.77%)

1.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.0
/packages/wasm_run/lib/src/ffi/io.dart
1
import 'dart:ffi';
2
import 'dart:io';
3
import 'dart:typed_data';
4

5
import 'package:wasm_run/src/bridge_generated.dart';
6
import 'package:wasm_run/src/ffi/library_locator.dart';
7
import 'package:wasm_run/src/ffi/setup_dynamic_library.dart';
8

9
typedef ExternalLibrary = DynamicLibrary;
10

11
Future<void> setUpLibraryImpl({required bool features, required bool wasi}) =>
×
12
    setUpDesktopDynamicLibrary();
×
13

14
WasmRunDart createWrapperImpl(ExternalLibrary dylib) {
3✔
15
  final validated = _validateLibrary(dylib);
3✔
16
  return WasmRunDartImpl(validated);
3✔
17
}
18

19
ExternalLibrary localTestingLibraryImpl() {
3✔
20
  final filename = getDesktopLibName();
3✔
21
  bool isRelease = true;
22
  assert(
23
    (() {
6✔
24
      isRelease = false;
25
      return true;
26
    })(),
3✔
27
    '',
28
  );
29
  final buildProfile = isRelease ? 'release' : 'debug';
30
  for (final dir in [
3✔
31
    '../../target/$buildProfile/$filename',
3✔
32
    '../../../target/$buildProfile/$filename',
3✔
33
    '../../../../target/$buildProfile/$filename',
3✔
34
    if (!isRelease) '../../target/release/$filename',
3✔
35
    if (!isRelease) '../../../target/release/$filename',
3✔
36
    if (!isRelease) '../../../../target/release/$filename',
3✔
37
  ]) {
3✔
38
    if (!File(dir).existsSync()) continue;
6✔
39
    print('Using localTestingLibrary: ${File(dir).absolute.uri.toFilePath()}');
18✔
40
    return _validateLibrary(DynamicLibrary.open(dir));
6✔
41
  }
42
  throw Exception('Could not find $filename in debug or release');
×
43
}
44

45
ExternalLibrary createLibraryImpl() {
3✔
46
  final envPath = Platform.environment[dynamicLibraryEnvVariable];
6✔
47
  if (envPath != null) {
48
    return _validateLibrary(DynamicLibrary.open(envPath));
×
49
  }
50
  try {
51
    final DynamicLibrary library;
52
    if (Platform.isIOS || Platform.isMacOS) {
6✔
53
      try {
54
        return _validateLibrary(DynamicLibrary.executable());
×
55
      } catch (_) {}
56
      library = DynamicLibrary.open(appleLib);
×
57
    } else if (Platform.isWindows) {
3✔
58
      library = DynamicLibrary.open(windowsLib);
×
59
    } else {
60
      library = DynamicLibrary.open(linuxLib);
3✔
61
    }
62

63
    return _validateLibrary(library);
×
64
  } catch (_) {
65
    try {
66
      final nativeDir = libBuildOutDir();
3✔
67
      final libName = getDesktopLibName();
3✔
68
      final lib = DynamicLibrary.open(nativeDir.resolve(libName).toFilePath());
9✔
69
      return _validateLibrary(lib);
×
70
    } catch (_) {}
71
    try {
72
      return localTestingLibraryImpl();
3✔
73
    } catch (_) {}
74

75
    throw Exception(
×
76
      'WasmRun library not found. Did you run `dart run wasm_run:setup`?',
77
    );
78
  }
79
}
80

81
DynamicLibrary _validateLibrary(DynamicLibrary library) {
3✔
82
  if (library.providesSymbol('wire_compile_wasm')) {
3✔
83
    return library;
84
  }
85
  throw Exception('Invalid library $library');
×
86
}
87

88
Future<Uint8List> getUriBodyBytesImpl(Uri uri) async {
1✔
89
  final client = HttpClient();
1✔
90
  final request = await client.getUrl(uri);
1✔
91
  final response = await request.close();
1✔
92
  if (response.contentLength == 0) {
2✔
93
    throw Exception('Failed to fetch $uri: ${response.statusCode}');
×
94
  }
95
  final bytes = await response.fold(
1✔
96
    BytesBuilder(),
1✔
97
    (b, d) => b..add(d),
2✔
98
  );
99
  return bytes.takeBytes();
1✔
100
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc