Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dcharkes committed Jan 9, 2025
1 parent 982230f commit 03e1851
Showing 1 changed file with 41 additions and 33 deletions.
74 changes: 41 additions & 33 deletions pkgs/native_toolchain_c/test/cbuilder/compiler_resolver_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,39 +42,47 @@ void main() {
].firstOrNull?.uri;

final targetOS = OS.current;
final buildInputBuilder = BuildInputBuilder()
..setupShared(
packageName: 'dummy',
packageRoot: tempUri,
outputDirectory: tempUri,
outputDirectoryShared: tempUri2,
)
..config.setupBuild(
linkingEnabled: false,
dryRun: false,
)
..config.setupShared(buildAssetTypes: [CodeAsset.type])
..config.setupCode(
targetOS: targetOS,
macOS: targetOS == OS.macOS
? MacOSConfig(targetVersion: defaultMacOSVersion)
: null,
targetArchitecture: Architecture.current,
linkModePreference: LinkModePreference.dynamic,
cCompiler: CCompilerConfig(
archiver: ar,
compiler: cc,
linker: ld,
envScript: envScript,
),
);
final buildInput = BuildInput(buildInputBuilder.json);
final resolver =
CompilerResolver(codeConfig: buildInput.config.code, logger: logger);
final compiler = await resolver.resolveCompiler();
final archiver = await resolver.resolveArchiver();
expect(compiler.uri, buildInput.config.code.cCompiler?.compiler);
expect(archiver.uri, buildInput.config.code.cCompiler?.archiver);
for (final passInEnvScript in [if (targetOS == OS.windows) true, false]) {
final buildInputBuilder = BuildInputBuilder()
..setupShared(
packageName: 'dummy',
packageRoot: tempUri,
outputDirectory: tempUri,
outputDirectoryShared: tempUri2,
)
..config.setupBuild(
linkingEnabled: false,
dryRun: false,
)
..config.setupShared(buildAssetTypes: [CodeAsset.type])
..config.setupCode(
targetOS: targetOS,
macOS: targetOS == OS.macOS
? MacOSConfig(targetVersion: defaultMacOSVersion)
: null,
targetArchitecture: Architecture.current,
linkModePreference: LinkModePreference.dynamic,
cCompiler: CCompilerConfig(
archiver: ar,
compiler: cc,
linker: ld,
envScript: passInEnvScript ? envScript : null,
),
);
final buildInput = BuildInput(buildInputBuilder.json);
final resolver =
CompilerResolver(codeConfig: buildInput.config.code, logger: logger);
final compiler = await resolver.resolveCompiler();
final archiver = await resolver.resolveArchiver();
expect(compiler.uri, buildInput.config.code.cCompiler?.compiler);
expect(archiver.uri, buildInput.config.code.cCompiler?.archiver);
final environment = await resolver.resolveEnvironment(compiler);
if (passInEnvScript) {
expect(environment, isNot(equals({})));
} else {
expect(environment, equals({}));
}
}
});

test('No compiler found', () async {
Expand Down

0 comments on commit 03e1851

Please sign in to comment.