update export windows tests

This commit is contained in:
Michael Angelo Calimlim 2023-11-05 22:26:25 +08:00
parent 59f5fcd5ea
commit a9e580c84b
2 changed files with 35 additions and 6 deletions

View file

@ -443,12 +443,13 @@ impl Processor for FtwCommand {
#[cfg(test)]
mod ftw_command_tests {
use super::*;
use crate::{
test_util::Project,
traits::{ToAppExt, ToLibExt, ToLibPrefix},
};
use assert_cmd::prelude::*;
use std::env;
use std::process::Command;
#[test]
fn test_is_valid_project_no_cargo_toml() {
@ -1030,6 +1031,14 @@ enable-cross-compilation=true
"bin/{target_cli_arg}/{project_name}.debug.{target_cli_arg}.pck"
)));
}
if target.is_windows() {
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}"
)));
@ -1038,8 +1047,9 @@ enable-cross-compilation=true
#[test]
fn test_process_ftw_command_cross_export_multi_target() {
let project = Project::new();
let project_name = project.get_name();
let cmd = FtwCommand::New {
project_name: project.get_name(),
project_name: project_name.clone(),
template: FtwTemplate::default(),
tag: FtwTag::default(),
};
@ -1051,7 +1061,12 @@ enable-cross-compilation=true
assert!(project
.read(".ftw")
.contains("enable-cross-compilation=true"));
let _ = env::set_current_dir(Path::new(&project.get_name()));
let _ = env::set_current_dir(Path::new(&project_name.clone()));
Command::new("cargo")
.arg("make")
.arg("switch-gdnlib-msvc-to-gnu-entry")
.assert()
.success();
let targets = vec![
FtwTarget::LinuxX86_64,
FtwTarget::MacOsX86_64,
@ -1067,9 +1082,7 @@ enable-cross-compilation=true
let cmd = FtwCommand::Clean;
let _ = cmd.process();
let _ = env::set_current_dir(Path::new("../"));
assert!(project
.read("rust/Cargo.toml")
.contains(&project.get_name()));
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();
@ -1088,6 +1101,9 @@ enable-cross-compilation=true
)));
}
if target.is_windows() {
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"
)));

View file

@ -9,6 +9,7 @@ use ftw::type_alias::StrTarget;
use ftw::util::get_current_platform;
use predicates;
use predicates::prelude::*;
use std::process::Command;
#[test]
fn test_ftw_export_no_target() {
@ -44,6 +45,9 @@ fn test_ftw_export_no_target() {
)));
}
if target.is_windows() {
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"
)));
@ -70,6 +74,12 @@ enable-cross-compilation=true
assert!(project
.read(".ftw")
.contains("enable-cross-compilation=true"));
Command::new("cargo")
.arg("make")
.arg("switch-gdnlib-msvc-to-gnu-entry")
.current_dir(&project_name)
.assert()
.success();
let targets = vec![
FtwTarget::MacOsAarch64,
FtwTarget::LinuxX86_64,
@ -106,6 +116,9 @@ enable-cross-compilation=true
)));
}
if target.is_windows() {
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"
)));