mirror of
https://github.com/macalimlim/ftw
synced 2024-11-10 04:24:12 +00:00
optimize tests
This commit is contained in:
parent
542fef91c7
commit
c957170cea
3 changed files with 83 additions and 873 deletions
|
@ -847,45 +847,6 @@ mod ftw_command_tests {
|
|||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_ftw_command_cross_build_linux_target() {
|
||||
let project = Project::new();
|
||||
let cmd = FtwCommand::New {
|
||||
project_name: project.get_name(),
|
||||
template: FtwTemplate::default(),
|
||||
tag: FtwTag::default(),
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let _ = env::set_current_dir(Path::new(&project.get_name()));
|
||||
let target = FtwTarget::LinuxX86_64;
|
||||
let targets = vec![target];
|
||||
let cmd = FtwCommand::Build {
|
||||
targets,
|
||||
build_type: FtwBuildType::Debug,
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let cmd = FtwCommand::Clean;
|
||||
let _ = cmd.process();
|
||||
let _ = env::set_current_dir(Path::new("../"));
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let project_name = project.get_name();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"lib/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_ftw_command_cross_build_multi_target() {
|
||||
let project = Project::new();
|
||||
|
@ -933,201 +894,6 @@ enable-cross-compilation=true
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_ftw_command_cross_build_windows_target() {
|
||||
let project = Project::new();
|
||||
let cmd = FtwCommand::New {
|
||||
project_name: project.get_name(),
|
||||
template: FtwTemplate::default(),
|
||||
tag: FtwTag::default(),
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let _ = env::set_current_dir(Path::new(&project.get_name()));
|
||||
let target = FtwTarget::WindowsX86_64Gnu;
|
||||
let targets = vec![target];
|
||||
let cmd = FtwCommand::Build {
|
||||
targets,
|
||||
build_type: FtwBuildType::Debug,
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let cmd = FtwCommand::Clean;
|
||||
let _ = cmd.process();
|
||||
let _ = env::set_current_dir(Path::new("../"));
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let project_name = project.get_name();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"lib/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_ftw_command_cross_build_macos_target() {
|
||||
let project = Project::new();
|
||||
let cmd = FtwCommand::New {
|
||||
project_name: project.get_name(),
|
||||
template: FtwTemplate::default(),
|
||||
tag: FtwTag::default(),
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let _ = env::set_current_dir(Path::new(&project.get_name()));
|
||||
let target = FtwTarget::MacOsX86_64;
|
||||
let targets = vec![target];
|
||||
let cmd = FtwCommand::Build {
|
||||
targets,
|
||||
build_type: FtwBuildType::Debug,
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let cmd = FtwCommand::Clean;
|
||||
let _ = cmd.process();
|
||||
let _ = env::set_current_dir(Path::new("../"));
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let project_name = project.get_name();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"lib/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_ftw_command_cross_build_macos_arm_target() {
|
||||
let project = Project::new();
|
||||
let cmd = FtwCommand::New {
|
||||
project_name: project.get_name(),
|
||||
template: FtwTemplate::default(),
|
||||
tag: FtwTag::default(),
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let _ = env::set_current_dir(Path::new(&project.get_name()));
|
||||
let target = FtwTarget::MacOsAarch64;
|
||||
let targets = vec![target];
|
||||
let cmd = FtwCommand::Build {
|
||||
targets,
|
||||
build_type: FtwBuildType::Debug,
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let cmd = FtwCommand::Clean;
|
||||
let _ = cmd.process();
|
||||
let _ = env::set_current_dir(Path::new("../"));
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let project_name = project.get_name();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"lib/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_ftw_command_cross_build_android_target() {
|
||||
let project = Project::new();
|
||||
let cmd = FtwCommand::New {
|
||||
project_name: project.get_name(),
|
||||
template: FtwTemplate::default(),
|
||||
tag: FtwTag::default(),
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let _ = env::set_current_dir(Path::new(&project.get_name()));
|
||||
let target = FtwTarget::AndroidLinuxAarch64;
|
||||
let targets = vec![target];
|
||||
let cmd = FtwCommand::Build {
|
||||
targets,
|
||||
build_type: FtwBuildType::Debug,
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let cmd = FtwCommand::Clean;
|
||||
let _ = cmd.process();
|
||||
let _ = env::set_current_dir(Path::new("../"));
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let project_name = project.get_name();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"lib/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_ftw_command_cross_build_ios_target() {
|
||||
let project = Project::new();
|
||||
let cmd = FtwCommand::New {
|
||||
project_name: project.get_name(),
|
||||
template: FtwTemplate::default(),
|
||||
tag: FtwTag::default(),
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let _ = env::set_current_dir(Path::new(&project.get_name()));
|
||||
let target = FtwTarget::IosAarch64;
|
||||
let targets = vec![target];
|
||||
let cmd = FtwCommand::Build {
|
||||
targets,
|
||||
build_type: FtwBuildType::Debug,
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let cmd = FtwCommand::Clean;
|
||||
let _ = cmd.process();
|
||||
let _ = env::set_current_dir(Path::new("../"));
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let project_name = project.get_name();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"lib/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_ftw_command_build_2x() {
|
||||
let project = Project::new();
|
||||
|
@ -1215,7 +981,7 @@ enable-cross-compilation=true
|
|||
let project_name = project.get_name();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
let target_app_ext = target.to_app_ext();
|
||||
if target == FtwTarget::LinuxX86_64 {
|
||||
if target.is_linux() {
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
|
@ -1228,98 +994,6 @@ enable-cross-compilation=true
|
|||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_ftw_command_cross_export_linux_target() {
|
||||
let project = Project::new();
|
||||
let cmd = FtwCommand::New {
|
||||
project_name: project.get_name(),
|
||||
template: FtwTemplate::default(),
|
||||
tag: FtwTag::default(),
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let _ = env::set_current_dir(Path::new(&project.get_name()));
|
||||
let target = FtwTarget::LinuxX86_64;
|
||||
let targets = vec![target];
|
||||
let cmd = FtwCommand::Export {
|
||||
targets,
|
||||
build_type: FtwBuildType::Debug,
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let cmd = FtwCommand::Clean;
|
||||
let _ = cmd.process();
|
||||
let _ = env::set_current_dir(Path::new("../"));
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let project_name = project.get_name();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
let target_app_ext = target.to_app_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}.pck"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}{target_app_ext}"
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_ftw_command_cross_export_ios_target() {
|
||||
let project = Project::new();
|
||||
let cmd = FtwCommand::New {
|
||||
project_name: project.get_name(),
|
||||
template: FtwTemplate::default(),
|
||||
tag: FtwTag::default(),
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let _ = env::set_current_dir(Path::new(&project.get_name()));
|
||||
let target = FtwTarget::IosAarch64;
|
||||
let targets = vec![target];
|
||||
let cmd = FtwCommand::Export {
|
||||
targets: targets.clone(),
|
||||
build_type: FtwBuildType::Debug,
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let cmd = FtwCommand::Clean;
|
||||
let _ = cmd.process();
|
||||
let _ = env::set_current_dir(Path::new("../"));
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let project_name = project.get_name();
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}.pck"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}.xcframework"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}.xcodeproj"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}"
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_ftw_command_cross_export_multi_target() {
|
||||
let project = Project::new();
|
||||
|
@ -1361,7 +1035,10 @@ enable-cross-compilation=true
|
|||
let project_name = project.get_name();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
let target_app_ext = target.to_app_ext();
|
||||
if target == FtwTarget::LinuxX86_64 {
|
||||
assert!(project.exists(&format!(
|
||||
"lib/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
if target.is_linux() {
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
|
@ -1369,7 +1046,7 @@ enable-cross-compilation=true
|
|||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}.pck"
|
||||
)));
|
||||
}
|
||||
if target == FtwTarget::IosAarch64 {
|
||||
if target.is_ios() {
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}.pck"
|
||||
)));
|
||||
|
@ -1383,87 +1060,11 @@ enable-cross-compilation=true
|
|||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}"
|
||||
)));
|
||||
}
|
||||
if target != FtwTarget::IosAarch64 {
|
||||
if !target.is_ios() {
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}{target_app_ext}"
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_ftw_command_cross_export_macos_target() {
|
||||
let project = Project::new();
|
||||
let cmd = FtwCommand::New {
|
||||
project_name: project.get_name(),
|
||||
template: FtwTemplate::default(),
|
||||
tag: FtwTag::default(),
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let _ = env::set_current_dir(Path::new(&project.get_name()));
|
||||
let target = FtwTarget::MacOsX86_64;
|
||||
let targets = vec![target];
|
||||
let cmd = FtwCommand::Export {
|
||||
targets,
|
||||
build_type: FtwBuildType::Debug,
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let cmd = FtwCommand::Clean;
|
||||
let _ = cmd.process();
|
||||
let _ = env::set_current_dir(Path::new("../"));
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let project_name = project.get_name();
|
||||
let target_app_ext = target.to_app_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}{target_app_ext}"
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_ftw_command_cross_export_macos_arm_target() {
|
||||
let project = Project::new();
|
||||
let cmd = FtwCommand::New {
|
||||
project_name: project.get_name(),
|
||||
template: FtwTemplate::default(),
|
||||
tag: FtwTag::default(),
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let _ = env::set_current_dir(Path::new(&project.get_name()));
|
||||
let target = FtwTarget::MacOsAarch64;
|
||||
let targets = vec![target];
|
||||
let cmd = FtwCommand::Export {
|
||||
targets,
|
||||
build_type: FtwBuildType::Debug,
|
||||
};
|
||||
let _ = cmd.process();
|
||||
let cmd = FtwCommand::Clean;
|
||||
let _ = cmd.process();
|
||||
let _ = env::set_current_dir(Path::new("../"));
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let project_name = project.get_name();
|
||||
let target_app_ext = target.to_app_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}{target_app_ext}"
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@ use assert_cmd::prelude::*;
|
|||
use common::ftw;
|
||||
use ftw::ftw_target::FtwTarget;
|
||||
use ftw::test_util::Project;
|
||||
use ftw::traits::{ToCliArg, ToLibExt, ToLibPrefix};
|
||||
use ftw::traits::{ToCliArg, ToLibExt, ToLibPrefix, ToStrTarget};
|
||||
use ftw::type_alias::StrTarget;
|
||||
use ftw::util::get_current_platform;
|
||||
use predicates;
|
||||
use predicates::prelude::*;
|
||||
|
@ -37,246 +38,6 @@ fn test_ftw_build_no_target() {
|
|||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ftw_cross_build_linux_target() {
|
||||
let project = Project::new();
|
||||
ftw()
|
||||
.arg("new")
|
||||
.arg(&project.get_name())
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicates::str::contains("SUCCESS").from_utf8());
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let target = FtwTarget::LinuxX86_64;
|
||||
ftw()
|
||||
.arg("build")
|
||||
.arg("linux-x86_64")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let project_name = project.get_name();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"lib/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
ftw()
|
||||
.arg("clean")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ftw_cross_build_windows_target() {
|
||||
let project = Project::new();
|
||||
ftw()
|
||||
.arg("new")
|
||||
.arg(&project.get_name())
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicates::str::contains("SUCCESS").from_utf8());
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let target = FtwTarget::WindowsX86_64Gnu;
|
||||
ftw()
|
||||
.arg("build")
|
||||
.arg("windows-x86_64-gnu")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let project_name = project.get_name();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"lib/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
ftw()
|
||||
.arg("clean")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ftw_cross_build_macos_target() {
|
||||
let project = Project::new();
|
||||
ftw()
|
||||
.arg("new")
|
||||
.arg(&project.get_name())
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicates::str::contains("SUCCESS").from_utf8());
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let target = FtwTarget::MacOsX86_64;
|
||||
ftw()
|
||||
.arg("build")
|
||||
.arg("macos-x86_64")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let project_name = project.get_name();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"lib/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
ftw()
|
||||
.arg("clean")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ftw_cross_build_macos_arm_target() {
|
||||
let project = Project::new();
|
||||
ftw()
|
||||
.arg("new")
|
||||
.arg(&project.get_name())
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicates::str::contains("SUCCESS").from_utf8());
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let target = FtwTarget::MacOsAarch64;
|
||||
ftw()
|
||||
.arg("build")
|
||||
.arg("macos-aarch64")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let project_name = project.get_name();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"lib/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
ftw()
|
||||
.arg("clean")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ftw_cross_build_android_target() {
|
||||
let project = Project::new();
|
||||
ftw()
|
||||
.arg("new")
|
||||
.arg(&project.get_name())
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicates::str::contains("SUCCESS").from_utf8());
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let target = FtwTarget::AndroidLinuxAarch64;
|
||||
ftw()
|
||||
.arg("build")
|
||||
.arg("android-aarch64")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let project_name = project.get_name();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"lib/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
ftw()
|
||||
.arg("clean")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ftw_cross_build_ios_target() {
|
||||
let project = Project::new();
|
||||
ftw()
|
||||
.arg("new")
|
||||
.arg(&project.get_name())
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicates::str::contains("SUCCESS").from_utf8());
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let target = FtwTarget::IosAarch64;
|
||||
ftw()
|
||||
.arg("build")
|
||||
.arg("ios-aarch64")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let project_name = project.get_name();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"lib/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
ftw()
|
||||
.arg("clean")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ftw_cross_build_multi_target() {
|
||||
let project = Project::new();
|
||||
|
@ -293,15 +54,6 @@ enable-cross-compilation=true
|
|||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
ftw()
|
||||
.arg("build")
|
||||
.arg("macos-aarch64,windows-x86_64-gnu,linux-x86_64,macos-x86_64,android-aarch64,ios-aarch64")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let targets = vec![
|
||||
FtwTarget::AndroidLinuxAarch64,
|
||||
FtwTarget::MacOsAarch64,
|
||||
|
@ -310,6 +62,20 @@ enable-cross-compilation=true
|
|||
FtwTarget::WindowsX86_64Gnu,
|
||||
FtwTarget::IosAarch64,
|
||||
];
|
||||
let str_targets = targets
|
||||
.iter()
|
||||
.map(|target| target.to_str_target())
|
||||
.collect::<Vec<StrTarget>>()
|
||||
.join(",");
|
||||
ftw()
|
||||
.arg("build")
|
||||
.arg(str_targets)
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
for target in targets {
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
|
|
|
@ -4,179 +4,57 @@ use assert_cmd::prelude::*;
|
|||
use common::ftw;
|
||||
use ftw::ftw_target::FtwTarget;
|
||||
use ftw::test_util::Project;
|
||||
use ftw::traits::{ToAppExt, ToCliArg, ToLibExt, ToLibPrefix};
|
||||
use ftw::util::{get_crate_name_from_path, get_current_platform};
|
||||
use ftw::traits::{ToAppExt, ToCliArg, ToLibExt, ToLibPrefix, ToStrTarget};
|
||||
use ftw::type_alias::StrTarget;
|
||||
use ftw::util::get_current_platform;
|
||||
use predicates;
|
||||
use predicates::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn test_ftw_export_no_target() {
|
||||
let project = Project::new();
|
||||
let project_name = project.get_name();
|
||||
ftw()
|
||||
.arg("new")
|
||||
.arg(&project.get_name())
|
||||
.arg(&project_name)
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicates::str::contains("SUCCESS").from_utf8());
|
||||
ftw()
|
||||
.arg("export")
|
||||
.current_dir(&project.get_name())
|
||||
.current_dir(&project_name)
|
||||
.assert()
|
||||
.success();
|
||||
let current_platform = get_current_platform();
|
||||
let target: FtwTarget = current_platform.parse().unwrap();
|
||||
let project_name = project.get_name();
|
||||
let crate_name = get_crate_name_from_path(&format!("{project_name}/rust/")).unwrap();
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
assert!(project.read("rust/Cargo.toml").contains(&project_name));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
let target_app_ext = target.to_app_ext();
|
||||
if target == FtwTarget::LinuxX86_64 {
|
||||
assert!(project.exists(&format!(
|
||||
"lib/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
if target.is_linux() {
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}.pck"
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}.pck"
|
||||
)));
|
||||
}
|
||||
if target.is_windows() {
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}.pck"
|
||||
)));
|
||||
}
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}{target_app_ext}"
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}{target_app_ext}"
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ftw_cross_export_linux_target() {
|
||||
let project = Project::new();
|
||||
ftw()
|
||||
.arg("new")
|
||||
.arg(&project.get_name())
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicates::str::contains("SUCCESS").from_utf8());
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let target = FtwTarget::LinuxX86_64;
|
||||
ftw()
|
||||
.arg("export")
|
||||
.arg("linux-x86_64")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
ftw()
|
||||
.arg("clean")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
let project_name = project.get_name();
|
||||
let crate_name = get_crate_name_from_path(&format!("{project_name}/rust/")).unwrap();
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
let target_app_ext = target.to_app_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}.pck"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}{target_app_ext}"
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ftw_cross_export_macos_target() {
|
||||
let project = Project::new();
|
||||
ftw()
|
||||
.arg("new")
|
||||
.arg(&project.get_name())
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicates::str::contains("SUCCESS").from_utf8());
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let target = FtwTarget::MacOsX86_64;
|
||||
ftw()
|
||||
.arg("export")
|
||||
.arg("macos-x86_64")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
ftw()
|
||||
.arg("clean")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
let project_name = project.get_name();
|
||||
let crate_name = get_crate_name_from_path(&format!("{project_name}/rust/")).unwrap();
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_app_ext = target.to_app_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}{target_app_ext}"
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ftw_cross_export_macos_arm_target() {
|
||||
let project = Project::new();
|
||||
ftw()
|
||||
.arg("new")
|
||||
.arg(&project.get_name())
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicates::str::contains("SUCCESS").from_utf8());
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let target = FtwTarget::MacOsAarch64;
|
||||
ftw()
|
||||
.arg("export")
|
||||
.arg("macos-aarch64")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
ftw()
|
||||
.arg("clean")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
let project_name = project.get_name();
|
||||
let crate_name = get_crate_name_from_path(&format!("{project_name}/rust/")).unwrap();
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_app_ext = target.to_app_ext();
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}{target_app_ext}"
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ftw_cross_export_ios_target() {
|
||||
fn test_ftw_cross_export_multi_target() {
|
||||
let project = Project::new();
|
||||
let project_name = project.get_name();
|
||||
ftw()
|
||||
|
@ -192,104 +70,69 @@ enable-cross-compilation=true
|
|||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
let target = FtwTarget::IosAarch64;
|
||||
ftw()
|
||||
.arg("export")
|
||||
.arg("ios-aarch64")
|
||||
.current_dir(&project_name)
|
||||
.assert()
|
||||
.success();
|
||||
ftw()
|
||||
.arg("clean")
|
||||
.current_dir(&project_name)
|
||||
.assert()
|
||||
.success();
|
||||
let crate_name = get_crate_name_from_path(&format!("{project_name}/rust/")).unwrap();
|
||||
assert!(project.read("rust/Cargo.toml").contains(&project_name));
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}.pck"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}.xcframework"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}.xcodeproj"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}"
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ftw_cross_export_multi_target() {
|
||||
let project = Project::new();
|
||||
ftw()
|
||||
.arg("new")
|
||||
.arg(&project.get_name())
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicates::str::contains("SUCCESS").from_utf8());
|
||||
let contents = r#"[ftw]
|
||||
enable-cross-compilation=true
|
||||
"#;
|
||||
let _ = project.create(".ftw", contents);
|
||||
assert!(project
|
||||
.read(".ftw")
|
||||
.contains("enable-cross-compilation=true"));
|
||||
ftw()
|
||||
.arg("export")
|
||||
.arg("macos-aarch64,linux-x86_64,macos-x86_64,ios-aarch64")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
ftw()
|
||||
.arg("clean")
|
||||
.current_dir(&project.get_name())
|
||||
.assert()
|
||||
.success();
|
||||
let project_name = project.get_name();
|
||||
let crate_name = get_crate_name_from_path(&format!("{project_name}/rust/")).unwrap();
|
||||
assert!(project
|
||||
.read("rust/Cargo.toml")
|
||||
.contains(&project.get_name()));
|
||||
let targets = vec![
|
||||
FtwTarget::MacOsAarch64,
|
||||
FtwTarget::LinuxX86_64,
|
||||
FtwTarget::MacOsX86_64,
|
||||
FtwTarget::IosAarch64,
|
||||
FtwTarget::WindowsX86_64Gnu,
|
||||
];
|
||||
let str_targets = targets
|
||||
.iter()
|
||||
.map(|target| target.to_str_target())
|
||||
.collect::<Vec<StrTarget>>()
|
||||
.join(",");
|
||||
ftw()
|
||||
.arg("export")
|
||||
.arg(str_targets)
|
||||
.current_dir(&project_name)
|
||||
.assert()
|
||||
.success();
|
||||
assert!(project.read("rust/Cargo.toml").contains(&project_name));
|
||||
for target in targets {
|
||||
let target_cli_arg = target.to_cli_arg();
|
||||
let target_lib_prefix = target.to_lib_prefix();
|
||||
let target_lib_ext = target.to_lib_ext();
|
||||
let target_app_ext = target.to_app_ext();
|
||||
if target == FtwTarget::LinuxX86_64 {
|
||||
assert!(project.exists(&format!(
|
||||
"lib/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
if target.is_linux() {
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{target_lib_prefix}{project_name}.{target_lib_ext}"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}.pck"
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}.pck"
|
||||
)));
|
||||
}
|
||||
if target == FtwTarget::IosAarch64 {
|
||||
if target.is_windows() {
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}.pck"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}.xcframework"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}.xcodeproj"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}"
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}.pck"
|
||||
)));
|
||||
}
|
||||
if target != FtwTarget::IosAarch64 {
|
||||
if target.is_ios() {
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{crate_name}.debug.{target_cli_arg}{target_app_ext}"
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}.pck"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}.xcframework"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}.xcodeproj"
|
||||
)));
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}"
|
||||
)));
|
||||
}
|
||||
if !target.is_ios() {
|
||||
assert!(project.exists(&format!(
|
||||
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}{target_app_ext}"
|
||||
)));
|
||||
}
|
||||
}
|
||||
ftw()
|
||||
.arg("clean")
|
||||
.current_dir(&project_name)
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue