From eca5f6c13017f124b6fec9efb58599926e9ea3b5 Mon Sep 17 00:00:00 2001 From: Michal Budzynski Date: Wed, 18 Oct 2017 14:42:21 +0200 Subject: [PATCH 1/6] Fixed test fails on cargo beta due to missing [root] in Cargo.lock --- src/skeptic/Cargo.toml | 4 +-- src/skeptic/lib.rs | 55 +++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/skeptic/Cargo.toml b/src/skeptic/Cargo.toml index 0042687..61b042e 100644 --- a/src/skeptic/Cargo.toml +++ b/src/skeptic/Cargo.toml @@ -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] diff --git a/src/skeptic/lib.rs b/src/skeptic/lib.rs index b885ea9..b78c328 100644 --- a/src/skeptic/lib.rs +++ b/src/skeptic/lib.rs @@ -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; @@ -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; @@ -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; @@ -530,33 +528,43 @@ 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, } - #[derive(Clone, Copy)] - enum CompileType { - Full, - Check, + impl LockedDeps { + fn from_path>(pth: P) -> Result { + 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()); + + 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()) { @@ -569,15 +577,6 @@ pub mod rt { } } - impl CargoLock { - fn from_path>(pth: P) -> Result { - 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, @@ -643,14 +642,14 @@ pub mod rt { ) -> Result> { 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) }, )?; From 761bf8c42210fa4c84ecd6d79dd7fbaf1894331f Mon Sep 17 00:00:00 2001 From: Michal Budzynski Date: Wed, 18 Oct 2017 14:52:43 +0200 Subject: [PATCH 2/6] Also link with the workspace members. We used to link with the tested crate workspace members only implicitly via rustc following `extern crate` which led to collisions when crate under test was rebuilt. --- src/skeptic/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/skeptic/lib.rs b/src/skeptic/lib.rs index b78c328..f35573d 100644 --- a/src/skeptic/lib.rs +++ b/src/skeptic/lib.rs @@ -554,7 +554,8 @@ pub mod rt { .nodes .into_iter() .filter(|node| workspace_members.contains(&node.id)) - .flat_map(|node| node.dependencies.into_iter()); + .flat_map(|node| node.dependencies.into_iter()) + .chain(workspace_members.clone()); Ok(LockedDeps { dependencies: deps.collect() }) } From 25ca8f107ca6a64d03211485b3615c8b27f130a5 Mon Sep 17 00:00:00 2001 From: Michal Budzynski Date: Wed, 18 Oct 2017 14:53:03 +0200 Subject: [PATCH 3/6] Bumped version to 0.13.2 --- src/skeptic/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/skeptic/Cargo.toml b/src/skeptic/Cargo.toml index 61b042e..5f21f9e 100644 --- a/src/skeptic/Cargo.toml +++ b/src/skeptic/Cargo.toml @@ -4,7 +4,7 @@ authors = ["Brian Anderson ", 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" From 4c5a209359ab9960388ef212653937d829037ae3 Mon Sep 17 00:00:00 2001 From: Michal Budzynski Date: Wed, 18 Oct 2017 14:55:05 +0200 Subject: [PATCH 4/6] Enabled also beta in ci builds --- .travis.yml | 4 ++++ appveyor.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 99a07b4..54c8005 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/appveyor.yml b/appveyor.yml index 87a7392..ddc0c25 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,6 +17,10 @@ environment: - TARGET: x86_64-pc-windows-msvc # Testing other channels + - TARGET: x86_64-pc-windows-gnu + RUST_VERSION: beta + - TARGET: x86_64-pc-windows-msvc + RUST_VERSION: beta - TARGET: x86_64-pc-windows-gnu RUST_VERSION: nightly - TARGET: x86_64-pc-windows-msvc From 707f2209d0b24873c6fd268c970211af2f27ef48 Mon Sep 17 00:00:00 2001 From: Michal Budzynski Date: Thu, 19 Oct 2017 14:19:46 +0200 Subject: [PATCH 5/6] drop msys-gnu appveyor conf and skip appveyor cache restore --- appveyor.yml | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index ddc0c25..477449e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,35 +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: beta - TARGET: x86_64-pc-windows-msvc RUST_VERSION: beta - - TARGET: x86_64-pc-windows-gnu - RUST_VERSION: nightly - 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 @@ -54,12 +40,9 @@ test_script: cache: - C:\Users\appveyor\.cargo\registry - - target branches: only: - # Release tags - - /^v\d+\.\d+\.\d+.*$/ - master notifications: From bbce12d87de26ded00018dea8eea828a1a2c6373 Mon Sep 17 00:00:00 2001 From: Michal Budzynski Date: Thu, 19 Oct 2017 14:29:33 +0200 Subject: [PATCH 6/6] Updated the changelog for 0.13.2 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a14d645..12c4148 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)