Skip to content

Commit

Permalink
Switch from Travis CI to CircleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
felixc committed Jul 31, 2022
1 parent a05c5ad commit 7d741f3
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 53 deletions.
78 changes: 78 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
version: 2.1


commands:
build_and_test_steps:
description: "Build the library and test it"
steps:
- checkout
- run:
name: Install system dependencies
command: |
case "$(uname -s)" in
Linux*)
apt --quiet update
apt --yes install libgexiv2-dev
;;
Darwin*)
brew install gexiv2 pkg-config
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
;;
esac
- run:
name: Show environment info
command: |
rustc --version --verbose && echo ""
cargo --version --verbose && echo ""
case "$(uname -s)" in
Linux*)
dpkg --list libgexiv2-dev libexiv2-dev ;;
Darwin*)
brew list --versions gexiv2 exiv2 ;;
esac
- run:
name: Build
command: cargo build --verbose --all-features
- run:
name: Test
command: cargo test --verbose --all-features
- run:
name: Run Examples
command: |
cargo run --example gps
cargo run --example timestamp
linux_job_config: &linux_job_config
resource_class: small
steps:
- build_and_test_steps


jobs:
linux-msrv:
docker:
- image: rust:1.56-slim
<<: *linux_job_config
linux-stable:
docker:
- image: rust:slim
<<: *linux_job_config
linux-nightly:
docker:
- image: rustlang/rust:nightly-slim
<<: *linux_job_config
osx-stable:
macos:
xcode: "14.0.0"
steps:
- build_and_test_steps


workflows:
build-and-test:
jobs:
- linux-msrv
- linux-stable
- linux-nightly
- osx-stable
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
rexiv2
======

[![build-badge][]][build] &nbsp;
[![downloads-badge][]][crates-io] &nbsp;
[![version-badge][]][crates-io] &nbsp;
[![license-badge][]][license] &nbsp;
[![build-badge][]][build]&nbsp;
[![downloads-badge][]][crates-io]&nbsp;
[![version-badge][]][crates-io]&nbsp;
[![license-badge][]][license]&nbsp;

[build]: https://travis-ci.org/felixc/rexiv2
[build-badge]: https://img.shields.io/travis/felixc/rexiv2.svg
[build]: https://dl.circleci.com/status-badge/redirect/gh/felixc/rexiv2/tree/main
[build-badge]: https://dl.circleci.com/status-badge/img/gh/felixc/rexiv2/tree/main.svg?style=shield
[crates-io]: https://crates.io/crates/rexiv2
[downloads-badge]: https://img.shields.io/crates/d/rexiv2.svg
[version-badge]: https://img.shields.io/crates/v/rexiv2.svg
Expand Down
33 changes: 19 additions & 14 deletions tst/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

extern crate gexiv2_sys as gexiv2;
extern crate rexiv2;

use std::path::Path;
Expand All @@ -22,36 +23,36 @@ use std::sync::Once;
static INIT: Once = Once::new();

/// Should be called before any test runs. Will ensure that the library is initialized at most once.
fn setup_test() {
fn test_setup() {
INIT.call_once(|| rexiv2::initialize().expect("Unable to initialize rexiv2"));
}

#[test]
fn new_from_str_path() {
setup_test();
test_setup();
let sample_path = concat!(env!("CARGO_MANIFEST_DIR"), "/tst/sample.png");
let meta = rexiv2::Metadata::new_from_path(sample_path).unwrap();
assert_eq!(meta.get_media_type().unwrap(), rexiv2::MediaType::Png);
}

#[test]
fn new_from_path() {
setup_test();
test_setup();
let sample_path = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/tst/sample.png"));
let meta = rexiv2::Metadata::new_from_path(sample_path).unwrap();
assert_eq!(meta.get_media_type().unwrap(), rexiv2::MediaType::Png);
}

#[test]
fn new_from_buffer() {
setup_test();
test_setup();
let meta = rexiv2::Metadata::new_from_buffer(include_bytes!("sample.png")).unwrap();
assert_eq!(meta.get_media_type().unwrap(), rexiv2::MediaType::Png);
}

#[test]
fn new_from_buffer_error() {
setup_test();
test_setup();
let mut bytes = include_bytes!("sample.png").to_vec();
bytes.swap(0, 1);
let meta_result = rexiv2::Metadata::new_from_buffer(&bytes);
Expand All @@ -65,31 +66,35 @@ fn new_from_buffer_error() {

#[test]
fn supports_exif() {
setup_test();
test_setup();
let meta = rexiv2::Metadata::new_from_buffer(include_bytes!("sample.png")).unwrap();
assert_eq!(meta.supports_exif(), true);
}

#[test]
fn supports_iptc() {
setup_test();
test_setup();
let meta = rexiv2::Metadata::new_from_buffer(include_bytes!("sample.png")).unwrap();
assert_eq!(meta.supports_iptc(), true);
}

#[test]
fn supports_xmp() {
setup_test();
test_setup();
let meta = rexiv2::Metadata::new_from_buffer(include_bytes!("sample.png")).unwrap();
assert_eq!(meta.supports_xmp(), true);
}

#[test]
fn supports_bmff() {
setup_test();
// iPhone devices use the HEIC (BMFF) file format which only works properly after gexiv2 has been initialized
// (and the underlying libraries are the right version gexiv2 v0.13.0/Exiv2 v0.27.4)
// I copied a photo off an iPhone and shrunk it down to ensure that reading tags works
test_setup();

// iPhone devices use the HEIC (BMFF) file format which only works properly
// after gexiv2 has been initialized (and the underlying libraries are the
// right version gexiv2 v0.13.0/Exiv2 v0.27.4)
if unsafe { gexiv2::gexiv2_get_version() } < 1300 {
return;
}

let meta = rexiv2::Metadata::new_from_buffer(include_bytes!("sample.HEIC")).unwrap();
let gps = meta.get_gps_info().unwrap();
Expand All @@ -107,7 +112,7 @@ fn supports_bmff() {

#[test]
fn log_levels() {
setup_test();
test_setup();
assert_eq!(rexiv2::get_log_level(), rexiv2::LogLevel::WARN);
rexiv2::set_log_level(rexiv2::LogLevel::INFO);
assert_eq!(rexiv2::get_log_level(), rexiv2::LogLevel::INFO);
Expand All @@ -116,7 +121,7 @@ fn log_levels() {
#[test]
#[cfg(feature = "raw-tag-access")]
fn get_tag_raw() {
setup_test();
test_setup();
let meta = rexiv2::Metadata::new_from_buffer(include_bytes!("sample.png")).unwrap();
meta.set_tag_string("Exif.Image.DateTime", "2020:07:12 11:16:35")
.unwrap();
Expand Down

0 comments on commit 7d741f3

Please sign in to comment.