changeset 508:697925eecf6c

Add Travis CI configuration
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 16 Feb 2020 21:08:46 +0100
parents 8a64fe94a0b7
children d2ba412467c3
files .travis.yml examples/write-a-lot/src/main.rs src/cache.rs
diffstat 3 files changed, 73 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.travis.yml	Sun Feb 16 21:08:46 2020 +0100
@@ -0,0 +1,59 @@
+os:
+  - linux
+  - osx
+dist: bionic
+sudo: false
+addons:
+  apt:
+    packages:
+      # necessary for kcov
+      - libcurl4-openssl-dev
+      - libelf-dev
+      - libdw-dev
+      - libiberty-dev
+      - binutils-dev
+      - cmake
+      - gcc
+
+language: rust
+rust:
+  - stable
+  - nightly
+
+stages:
+  - name: test
+  - name: lint
+  - name: coverage
+
+install: true
+
+# Default script is the "test" stage
+script: 
+  - cargo build
+  - cargo test
+
+jobs:
+  include:
+    - stage: lint
+      if: os = linux
+      rust: stable
+      install:
+        - rustup component add rustfmt
+      script:
+        - cargo fmt --all -- --check
+
+    - stage: coverage
+      if: os = linux
+      sudo: true
+      rust: stable
+      env:
+        - RUSTFLAGS="-C link-dead-code -C debuginfo=2 -C opt-level=0"
+        - CACHE_NAME="coverage"
+      install:
+        - ./.travis/install-kcov.sh "v36" "29ccdde3bd44f14e0d7c88d709e1e5ff9b448e735538ae45ee08b73c19a2ea0b" && export PATH="kcov/usr/bin:${PATH}";
+      script:
+        - cargo test --no-run
+        - ./.travis/run-kcov.sh "yup_oauth2"
+        - bash <(curl -s https://codecov.io/bash) -F "${TRAVIS_RUST_VERSION}"
+
+cache: cargo
--- a/examples/write-a-lot/src/main.rs	Sun Feb 16 11:32:49 2020 +0100
+++ b/examples/write-a-lot/src/main.rs	Sun Feb 16 21:08:46 2020 +0100
@@ -17,7 +17,7 @@
     String::from_iter(rng.gen_ascii_chars().take(len))
 }
 
-fn fill_db(db: &mut DB, entries: usize) -> Result<(), Box<Error>> {
+fn fill_db(db: &mut DB, entries: usize) -> Result<(), Box<dyn Error>> {
     for i in 0..entries {
         let (k, v) = (gen_string(KEY_LEN), gen_string(VAL_LEN));
         db.put(k.as_bytes(), v.as_bytes())?;
--- a/src/cache.rs	Sun Feb 16 11:32:49 2020 +0100
+++ b/src/cache.rs	Sun Feb 16 21:08:46 2020 +0100
@@ -69,24 +69,20 @@
         if self.count() == 0 {
             return None;
         }
-        if self.head.prev.is_some() {
-            let mut lasto = unsafe {
-                replace(
-                    &mut (*((*self.head.prev.unwrap()).prev.unwrap())).next,
-                    None,
-                )
-            };
+        let mut lasto = unsafe {
+            replace(
+                &mut (*((*self.head.prev.unwrap()).prev.unwrap())).next,
+                None,
+            )
+        };
 
-            assert!(lasto.is_some());
-            if let Some(ref mut last) = lasto {
-                assert!(last.prev.is_some());
-                assert!(self.head.prev.is_some());
-                self.head.prev = last.prev;
-                self.count -= 1;
-                return replace(&mut (*last).data, None);
-            } else {
-                None
-            }
+        assert!(lasto.is_some());
+        if let Some(ref mut last) = lasto {
+            assert!(last.prev.is_some());
+            assert!(self.head.prev.is_some());
+            self.head.prev = last.prev;
+            self.count -= 1;
+            return replace(&mut (*last).data, None);
         } else {
             None
         }