diff --git a/Makefile b/Makefile index 5c9c83be6a2..14655872536 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ UNAME_S := $(shell uname -s) HAS_DOCKER := $(shell command -v docker 2> /dev/null) +TESTING_FS_ROOT := $(shell mktemp -d /tmp/testing-fs-root-XXXXXX) ifneq (${IN_DOCKER},) IN_DOCKER := ${IN_DOCKER} else ifeq ($(UNAME_S),Darwin) @@ -186,7 +187,7 @@ $(foreach component,$(ALL),$(eval $(call BUILD,$(component)))) define UNIT unit-$1: image ## executes the $1 component's unit test suite - $(run) sh -c 'cd components/$1 && cargo test $(CARGO_FLAGS)' + $(run) sh -c 'cd components/$1 && TESTING_FS_ROOT=$(TESTING_FS_ROOT) cargo test $(CARGO_FLAGS)' .PHONY: unit-$1 endef $(foreach component,$(ALL),$(eval $(call UNIT,$(component)))) diff --git a/components/common/src/templating/mod.rs b/components/common/src/templating/mod.rs index f5418e4c085..eeefb85b453 100644 --- a/components/common/src/templating/mod.rs +++ b/components/common/src/templating/mod.rs @@ -118,6 +118,10 @@ fn never_escape(data: &str) -> String { #[cfg(test)] mod test { + use super::*; + use crate::hcore::fs::{pkg_root_path, FS_ROOT_PATH}; + use crate::hcore::package::PackageIdent; + use crate::templating::test_helpers::*; use serde_json; use std::collections::BTreeMap; use std::env; @@ -127,12 +131,6 @@ mod test { use tempfile::TempDir; use toml; - use crate::hcore::fs::FS_ROOT_PATH; - use crate::hcore::package::PackageIdent; - - use super::*; - use crate::templating::test_helpers::*; - pub fn root() -> PathBuf { PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests") } @@ -309,7 +307,7 @@ test: something"# let rendered = renderer.render("t", &data).unwrap(); assert_eq!( PathBuf::from(rendered), - (&*FS_ROOT_PATH).join("/hab/pkgs/core/acl/2.2.52/20161208223311",) + pkg_root_path(Some(&*FS_ROOT_PATH)).join("core/acl/2.2.52/20161208223311",) ); } diff --git a/support/ci/rust_tests.sh b/support/ci/rust_tests.sh index 34d9156b0e0..0947cb24f67 100755 --- a/support/ci/rust_tests.sh +++ b/support/ci/rust_tests.sh @@ -1,8 +1,5 @@ #!/bin/bash -sudo mkdir -p /hab -sudo chmod o+w /hab - git log HEAD~1..HEAD | grep -q '!!! Temporary Commit !!!' is_tmp_commit=$?