Skip to content

Commit

Permalink
Merge pull request #43 from rodrimati1992/0.9
Browse files Browse the repository at this point in the history
Fixed up the version testing crates.
  • Loading branch information
rodrimati1992 authored Nov 21, 2020
2 parents 4fdd4ff + 30070de commit 54de29d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ script:


- cd "${TRAVIS_BUILD_DIR}/testing/version_compatibility/user_0"
- cargo run --features run
- cargo run
4 changes: 2 additions & 2 deletions testing/version_compatibility/impl_0/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ authors = ["rodrimati1992 <rodrimatt1985@gmail.com>"]
edition = "2018"

[dependencies]
abi_stable={path="../../../abi_stable",package="abi_stable"}
# abi_stable={version="*"}
# abi_stable={path="../../../abi_stable",package="abi_stable"}
abi_stable={version="*"}

[dependencies.version_compatibility_interface]
version="0.1"
Expand Down
2 changes: 1 addition & 1 deletion testing/version_compatibility/interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ old=[]
new=[]

[dependencies]
# old_abi_stable={version="*",package="abi_stable"}
old_abi_stable={version="*",package="abi_stable"}
new_abi_stable={path="../../../abi_stable",package="abi_stable"}
10 changes: 5 additions & 5 deletions testing/version_compatibility/interface/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

// #[cfg(feature="new")]
#[cfg(feature="new")]
extern crate new_abi_stable as abi_stable;

// #[cfg(not(feature="new"))]
// extern crate old_abi_stable as abi_stable;
#[cfg(not(feature="new"))]
extern crate old_abi_stable as abi_stable;

// #[cfg(all(feature="new",feature="old"))]
// compile_error!{"the new and old feature can't be enabled at the same time"}
#[cfg(all(feature="new",feature="old"))]
compile_error!{"the new and old feature can't be enabled at the same time"}


use abi_stable::{
Expand Down
9 changes: 1 addition & 8 deletions testing/version_compatibility/user_0/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@ version = "0.1.0"
authors = ["rodrimati1992 <rodrimatt1985@gmail.com>"]
edition = "2018"

[features]
"run" = [
"version_compatibility_interface/new",
"version_compatibility_interface/old",
]

[dependencies]
abi_stable={path="../../../abi_stable"}
core_extensions={ version = "0.1.18", default_features = false }



[dependencies.version_compatibility_interface]
version="0.1"
path="../interface"
features = ["new"]
17 changes: 10 additions & 7 deletions testing/version_compatibility/user_0/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,35 @@ fn compute_library_dir()->io::Result<PathBuf>{


fn main()-> io::Result<()> {
if cfg!(not(feature = "run")) {
panic!(r#"Please compile this with --feature run "#);
}

let library_dir=compute_library_dir().unwrap();

(||->Result<(),LibraryError>{
let header=abi_header_from_path(&RootMod_Ref::get_library_path(&library_dir))?;

println!("header: {:?}", header);
println!();
println!("Executable's AbiHeader {:?}", AbiHeader::VALUE);
println!();
println!("Executable's abi_stable version {:?}", abi_stable::ABI_STABLE_VERSION);

println!();

if header.is_valid() {
let lib_header=header.upgrade()?;

println!("Loaded AbiHeader {:?}", header);

unsafe{
let root=lib_header.init_root_module_with_unchecked_layout::<RootMod_Ref>()?;
println!("Loaded abi_stable version {:?}", root.abi_stable_version());
println!();
}


lib_header.check_layout::<RootMod_Ref>()?;
println!("\
The types in abi_stable on crates.io are compatible with those on \
the \"local\" repository\
");
} else {
println!("The abi_stable on crates.io isn't semver compatible with this one");
}
Ok(())
})().unwrap_or_else(|e| panic!("{}", e) );
Expand Down

0 comments on commit 54de29d

Please sign in to comment.