import tor package
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// SPDX-FileCopyrightText: 2024 Foundation Devices Inc.
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import 'package:build_tool/src/builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('parseBuildConfiguration', () {
|
||||
var b = BuildEnvironment.parseBuildConfiguration('debug');
|
||||
expect(b, BuildConfiguration.debug);
|
||||
|
||||
b = BuildEnvironment.parseBuildConfiguration('profile');
|
||||
expect(b, BuildConfiguration.profile);
|
||||
|
||||
b = BuildEnvironment.parseBuildConfiguration('release');
|
||||
expect(b, BuildConfiguration.release);
|
||||
|
||||
b = BuildEnvironment.parseBuildConfiguration('debug-dev');
|
||||
expect(b, BuildConfiguration.debug);
|
||||
|
||||
b = BuildEnvironment.parseBuildConfiguration('profile');
|
||||
expect(b, BuildConfiguration.profile);
|
||||
|
||||
b = BuildEnvironment.parseBuildConfiguration('profile-prod');
|
||||
expect(b, BuildConfiguration.profile);
|
||||
|
||||
// fallback to release
|
||||
b = BuildEnvironment.parseBuildConfiguration('unknown');
|
||||
expect(b, BuildConfiguration.release);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// SPDX-FileCopyrightText: 2024 Foundation Devices Inc.
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import 'package:build_tool/src/cargo.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
final _cargoToml = """
|
||||
[workspace]
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
panic = "abort"
|
||||
opt-level = "z"
|
||||
# strip = "symbols"
|
||||
|
||||
[package]
|
||||
name = "super_native_extensions"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
resolver = "2"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "staticlib"]
|
||||
""";
|
||||
|
||||
void main() {
|
||||
test('parseCargoToml', () {
|
||||
final info = CrateInfo.parseManifest(_cargoToml);
|
||||
expect(info.packageName, 'super_native_extensions');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
// SPDX-FileCopyrightText: 2024 Foundation Devices Inc.
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import 'package:build_tool/src/builder.dart';
|
||||
import 'package:build_tool/src/options.dart';
|
||||
import 'package:hex/hex.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
void main() {
|
||||
test('parseCargoBuildOptions', () {
|
||||
final yaml = """
|
||||
toolchain: nightly
|
||||
extra_flags:
|
||||
- -Z
|
||||
# Comment here
|
||||
- build-std=panic_abort,std
|
||||
""";
|
||||
final node = loadYamlNode(yaml);
|
||||
final options = CargoBuildOptions.parse(node);
|
||||
expect(options.toolchain, Toolchain.nightly);
|
||||
expect(options.flags, ['-Z', 'build-std=panic_abort,std']);
|
||||
});
|
||||
|
||||
test('parsePrecompiledBinaries', () {
|
||||
final yaml = """
|
||||
url_prefix: https://url-prefix
|
||||
public_key: a4c3433798eb2c36edf2b94dbb4dd899d57496ca373a8982d8a792410b7f6445
|
||||
""";
|
||||
final precompiledBinaries = PrecompiledBinaries.parse(loadYamlNode(yaml));
|
||||
final key = HEX.decode(
|
||||
'a4c3433798eb2c36edf2b94dbb4dd899d57496ca373a8982d8a792410b7f6445');
|
||||
expect(precompiledBinaries.uriPrefix, 'https://url-prefix');
|
||||
expect(precompiledBinaries.publicKey.bytes, key);
|
||||
});
|
||||
|
||||
test('parseCargokitOptions', () {
|
||||
const yaml = '''
|
||||
cargo:
|
||||
# For smalles binaries rebuilt the standard library with panic=abort
|
||||
debug:
|
||||
toolchain: nightly
|
||||
extra_flags:
|
||||
- -Z
|
||||
# Comment here
|
||||
- build-std=panic_abort,std
|
||||
release:
|
||||
toolchain: beta
|
||||
|
||||
precompiled_binaries:
|
||||
url_prefix: https://url-prefix
|
||||
public_key: a4c3433798eb2c36edf2b94dbb4dd899d57496ca373a8982d8a792410b7f6445
|
||||
''';
|
||||
final options = CargokitCrateOptions.parse(loadYamlNode(yaml));
|
||||
expect(options.precompiledBinaries?.uriPrefix, 'https://url-prefix');
|
||||
final key = HEX.decode(
|
||||
'a4c3433798eb2c36edf2b94dbb4dd899d57496ca373a8982d8a792410b7f6445');
|
||||
expect(options.precompiledBinaries?.publicKey.bytes, key);
|
||||
|
||||
final debugOptions = options.cargo[BuildConfiguration.debug]!;
|
||||
expect(debugOptions.toolchain, Toolchain.nightly);
|
||||
expect(debugOptions.flags, ['-Z', 'build-std=panic_abort,std']);
|
||||
|
||||
final releaseOptions = options.cargo[BuildConfiguration.release]!;
|
||||
expect(releaseOptions.toolchain, Toolchain.beta);
|
||||
expect(releaseOptions.flags, []);
|
||||
});
|
||||
|
||||
test('parseCargokitUserOptions', () {
|
||||
const yaml = '''
|
||||
use_precompiled_binaries: false
|
||||
verbose_logging: true
|
||||
''';
|
||||
final options = CargokitUserOptions.parse(loadYamlNode(yaml));
|
||||
expect(options.usePrecompiledBinaries, false);
|
||||
expect(options.verboseLogging, true);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import 'package:build_tool/src/rustup.dart';
|
||||
import 'package:build_tool/src/util.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('rustup with no toolchains', () {
|
||||
bool didListToolchains = false;
|
||||
bool didInstallStable = false;
|
||||
bool didListTargets = false;
|
||||
testRunCommandOverride = (args) {
|
||||
expect(args.executable, 'rustup');
|
||||
switch (args.arguments) {
|
||||
case ['toolchain', 'list']:
|
||||
didListToolchains = true;
|
||||
return TestRunCommandResult(stdout: 'no installed toolchains\n');
|
||||
case ['toolchain', 'install', 'stable']:
|
||||
didInstallStable = true;
|
||||
return TestRunCommandResult();
|
||||
case ['target', 'list', '--toolchain', 'stable', '--installed']:
|
||||
didListTargets = true;
|
||||
return TestRunCommandResult(
|
||||
stdout: 'x86_64-unknown-linux-gnu\nx86_64-apple-darwin\n');
|
||||
default:
|
||||
throw Exception('Unexpected call: ${args.arguments}');
|
||||
}
|
||||
};
|
||||
final rustup = Rustup();
|
||||
rustup.installToolchain('stable');
|
||||
expect(didInstallStable, true);
|
||||
expect(didListToolchains, true);
|
||||
expect(didListTargets, true);
|
||||
expect(rustup.installedTargets('stable'), [
|
||||
'x86_64-unknown-linux-gnu',
|
||||
'x86_64-apple-darwin',
|
||||
]);
|
||||
testRunCommandOverride = null;
|
||||
});
|
||||
|
||||
test('rustup with esp toolchain', () {
|
||||
final targetsQueried = <String>[];
|
||||
testRunCommandOverride = (args) {
|
||||
expect(args.executable, 'rustup');
|
||||
switch (args.arguments) {
|
||||
case ['toolchain', 'list']:
|
||||
return TestRunCommandResult(
|
||||
stdout: 'stable-aarch64-apple-darwin (default)\n'
|
||||
'nightly-aarch64-apple-darwin\n'
|
||||
'esp\n');
|
||||
case ['target', 'list', '--toolchain', String toolchain, '--installed']:
|
||||
targetsQueried.add(toolchain);
|
||||
return TestRunCommandResult(stdout: '$toolchain:target\n');
|
||||
default:
|
||||
throw Exception('Unexpected call: ${args.arguments}');
|
||||
}
|
||||
};
|
||||
final rustup = Rustup();
|
||||
expect(targetsQueried, [
|
||||
'stable-aarch64-apple-darwin',
|
||||
'nightly-aarch64-apple-darwin',
|
||||
]);
|
||||
expect(rustup.installedTargets('stable'),
|
||||
['stable-aarch64-apple-darwin:target']);
|
||||
expect(rustup.installedTargets('nightly'),
|
||||
['nightly-aarch64-apple-darwin:target']);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user