Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two problems with dependency testing on beta and enable beta in CI #66

Merged
merged 6 commits into from
Oct 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ matrix:
include:
- os: linux
rust: stable
- os: linux
rust: beta
- os: linux
rust: nightly
- os: osx
rust: stable
- os: osx
rust: beta
- os: osx
rust: nightly

Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 0.13.2

* [Fixed testfails on cargo beta due to missing root in Cargo.lock](https://github.com/budziq/rust-skeptic/pull/66)
* [Fixed linking problems when workspace members were rebuild without clean](https://github.com/budziq/rust-skeptic/pull/66)

Contributors: Michał Budzyński

# 0.13.1

* [Prevented pulldown-cmark from pulling getopt dependency](https://github.com/budziq/rust-skeptic/pull/64)
Expand Down
19 changes: 3 additions & 16 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,21 @@
environment:
global:
RUST_VERSION: stable

APPVEYOR_CACHE_SKIP_RESTORE: true
CRATE_NAME: skeptic

matrix:
# MinGW
- TARGET: i686-pc-windows-gnu
- TARGET: x86_64-pc-windows-gnu

# MSVC
- TARGET: i686-pc-windows-msvc
- TARGET: x86_64-pc-windows-msvc

# Testing other channels
- TARGET: x86_64-pc-windows-gnu
RUST_VERSION: nightly
- TARGET: x86_64-pc-windows-msvc
RUST_VERSION: beta
- TARGET: x86_64-pc-windows-msvc
RUST_VERSION: nightly

install:
- ps: >-
If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') {
$Env:PATH += ';C:\msys64\mingw64\bin'
} ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') {
$Env:PATH += ';C:\msys64\mingw32\bin'
}
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
- rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION%
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
Expand All @@ -50,12 +40,9 @@ test_script:

cache:
- C:\Users\appveyor\.cargo\registry
- target

branches:
only:
# Release tags
- /^v\d+\.\d+\.\d+.*$/
- master

notifications:
Expand Down
6 changes: 2 additions & 4 deletions src/skeptic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = ["Brian Anderson <[email protected]>",
description = "Test your Rust markdown documentation via Cargo"
license = "MIT/Apache-2.0"
name = "skeptic"
version = "0.13.1"
version = "0.13.2"
readme = "README.md"
repository = "https://github.com/budziq/rust-skeptic"
homepage = "https://github.com/budziq/rust-skeptic"
Expand All @@ -20,10 +20,8 @@ appveyor = { repository = "budziq/rust-skeptic" }
tempdir = "0.3.5"
glob = "0.2"
walkdir = "1.0"
serde = "1.0.15"
serde_derive = "1.0.15"
serde_json = "1.0.3"
toml = "0.4.5"
cargo_metadata = "0.3"
bytecount = "0.2.0"

[dev-dependencies]
Expand Down
56 changes: 28 additions & 28 deletions src/skeptic/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate serde_derive;
extern crate pulldown_cmark as cmark;
extern crate tempdir;
extern crate glob;
Expand Down Expand Up @@ -508,7 +506,7 @@ fn write_if_contents_changed(name: &Path, contents: &str) -> Result<(), IoError>

pub mod rt {
extern crate serde_json;
extern crate toml;
extern crate cargo_metadata;
extern crate walkdir;

use std::collections::HashMap;
Expand All @@ -517,7 +515,7 @@ pub mod rt {

use std::{self, env};
use std::fs::File;
use std::io::{self, Write, Read};
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use std::process::Command;
use std::ffi::OsStr;
Expand All @@ -530,33 +528,44 @@ pub mod rt {
errors { Fingerprint }
foreign_links {
Io(std::io::Error);
Toml(toml::de::Error);
Metadata(cargo_metadata::Error);
Json(serde_json::Error);
}
}

// An iterator over the root dependencies in a lockfile
#[derive(Deserialize, Debug)]
struct CargoLock {
root: Deps,
#[derive(Clone, Copy)]
enum CompileType {
Full,
Check,
}

#[derive(Deserialize, Debug)]
struct Deps {
// An iterator over the root dependencies in a lockfile
#[derive(Debug)]
struct LockedDeps {
dependencies: Vec<String>,
}

#[derive(Clone, Copy)]
enum CompileType {
Full,
Check,
impl LockedDeps {
fn from_path<P: AsRef<Path>>(pth: P) -> Result<LockedDeps> {
let pth = pth.as_ref().join("Cargo.toml");
let metadata = cargo_metadata::metadata_deps(Some(&pth), true)?;
let workspace_members = metadata.workspace_members;
let deps = metadata.resolve.ok_or("Missing dependency metadata")?
.nodes
.into_iter()
.filter(|node| workspace_members.contains(&node.id))
.flat_map(|node| node.dependencies.into_iter())
.chain(workspace_members.clone());

Ok(LockedDeps { dependencies: deps.collect() })
}
}

impl Iterator for CargoLock {
impl Iterator for LockedDeps {
type Item = (String, String);

fn next(&mut self) -> Option<(String, String)> {
self.root.dependencies.pop().and_then(|val| {
self.dependencies.pop().and_then(|val| {
let mut it = val.split_whitespace();

match (it.next(), it.next()) {
Expand All @@ -569,15 +578,6 @@ pub mod rt {
}
}

impl CargoLock {
fn from_path<P: AsRef<Path>>(pth: P) -> Result<CargoLock> {
let pth = pth.as_ref();
let mut contents = String::new();
File::open(pth)?.read_to_string(&mut contents)?;
Ok(toml::from_str(&contents)?)
}
}

#[derive(Debug)]
struct Fingerprint {
libname: String,
Expand Down Expand Up @@ -643,14 +643,14 @@ pub mod rt {
) -> Result<Vec<Fingerprint>> {
let root_dir = root_dir.as_ref();
let target_dir = target_dir.as_ref();
let lock = CargoLock::from_path(root_dir.join("Cargo.lock")).or_else(
let lock = LockedDeps::from_path(root_dir).or_else(
|_| {
// could not find Cargo.lock in $CARGO_MAINFEST_DIR
// try relative to target_dir
let mut root_dir = PathBuf::from(target_dir);
root_dir.pop();
root_dir.pop();
CargoLock::from_path(root_dir.join("Cargo.lock"))
LockedDeps::from_path(root_dir)
},
)?;

Expand Down