-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove legacy build-plan * add tests
- Loading branch information
Showing
25 changed files
with
335 additions
and
51 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ mod common; | |
|
||
pub mod build { | ||
pub mod simple; | ||
pub mod auto_target; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
use std::ffi::OsStr; | ||
use std::ffi::OsString; | ||
use std::path::Path; | ||
use std::path::PathBuf; | ||
use std::process::Output; | ||
use anyhow::Result; | ||
|
||
use ::build::consts::DEVICE_TARGET; | ||
use crate::common::*; | ||
|
||
|
||
fn run_build(crate_path: &Path, | ||
args: impl IntoIterator<Item = impl Into<OsString>>) | ||
-> Result<(Output, &'static Path)> { | ||
println!("crate: {}", crate_path.display()); | ||
|
||
let target_dir = target_dir(); | ||
let target_dir_arg = format!("--target-dir={}", target_dir.display()); | ||
let args = args.into_iter() | ||
.map(Into::into) | ||
.chain([OsString::from(target_dir_arg)]); | ||
let output = Tool::build(crate_path, args)?; | ||
assert!( | ||
output.status.success(), | ||
"Tool failed with stderr:\n{}", | ||
std::str::from_utf8(&output.stderr).unwrap() | ||
); | ||
Ok((output, target_dir)) | ||
} | ||
|
||
fn test_artifact_dev(path: &Path, _debug: bool) { | ||
println!("validating: {}", path.display()); | ||
assert!(path.exists(), "path does not exist: {}", path.display()); | ||
} | ||
|
||
|
||
fn export_dir(target_dir: &Path, target: &str, profile: &str) -> PathBuf { target_dir.join(target).join(profile) } | ||
|
||
|
||
#[test] | ||
fn bins_examples() -> Result<()> { | ||
let target = DEVICE_TARGET; | ||
let args = ["--device", "--bins", "--examples"].into_iter().map(OsStr::new); | ||
|
||
let path = auto_target()?; | ||
let (_, target_dir) = run_build(path, args.clone())?; | ||
let export_dir = export_dir(target_dir, target, "debug"); | ||
|
||
// check expectations: | ||
let package_name = "test-auto-target"; | ||
let cargo_package_name = to_cargo_package_crate_name(Path::new(package_name)).expect("package_crate_name"); | ||
for trg in ["test-auto-target", "auto-bin", "example-bin"] { | ||
let cargo_target_fullname = format!("{cargo_package_name}-{trg}"); | ||
let artifact = export_dir.join("playdate") | ||
.join(cargo_target_fullname) | ||
.join(PathBuf::from("build/pdex.elf")); | ||
println!("should be there: {artifact:?}"); | ||
test_artifact_dev(&artifact, false); | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
|
||
#[test] | ||
#[cfg_attr(windows, ignore = "Off until paths on Windows fixed.")] | ||
// Error on Windows: | ||
// failed to parse value from --config argument `target.thumbv7em-none-eabihf.rustflags=["-Ctarget-cpu=cortex-m7", "-Clink-args=--emit-relocs", "-Crelocation-model=pic", "-Csoft-float=no", "-Clink-arg=--cref", "-Clink-arg=--gc-sections", "-Clink-arg=--entry=eventHandlerShim", "-Clink-arg=-T\\?\\D:\\a\playdate\\playdate\\target\\tmp\\pd.x"]` as a dotted key expression | ||
fn bins_examples_no_gcc() -> Result<()> { | ||
let target = DEVICE_TARGET; | ||
let args = ["--device", "--bins", "--examples", "--no-gcc"].into_iter() | ||
.map(OsStr::new); | ||
|
||
let path = auto_target()?; | ||
let (_, target_dir) = run_build(path, args.clone())?; | ||
let export_dir = export_dir(target_dir, target, "debug"); | ||
|
||
// check expectations: | ||
let package_name = "test-auto-target"; | ||
let cargo_package_name = to_cargo_package_crate_name(Path::new(package_name)).expect("package_crate_name"); | ||
for trg in ["test-auto-target", "auto-bin", "example-bin"] { | ||
let cargo_target_fullname = format!("{cargo_package_name}-{trg}"); | ||
let artifact = export_dir.join("playdate") | ||
.join(cargo_target_fullname) | ||
.join(PathBuf::from("build/pdex.elf")); | ||
println!("should be there: {artifact:?}"); | ||
test_artifact_dev(&artifact, false); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "test-auto-target" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
autotests = false | ||
autobenches = false | ||
|
||
|
||
[dependencies.pd] | ||
package = "playdate-sys" | ||
path = "../../../../api/sys" | ||
features = ["lang-items"] | ||
|
||
|
||
[profile] | ||
dev.panic = "abort" | ||
release.panic = "abort" |
Oops, something went wrong.