Skip to content

Commit

Permalink
make all tests windows docker friendly
Browse files Browse the repository at this point in the history
Signed-off-by: mwrock <matt@mattwrock.com>
  • Loading branch information
mwrock committed Jun 4, 2019
1 parent ee7497d commit a7c7708
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 54 deletions.
68 changes: 34 additions & 34 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ steps:
shell: [ "powershell", "-Command" ]
always-pull: true
propagate-environment: true
timeout_in_minutes: 20
timeout_in_minutes: 25
soft_fail: true

- label: "[unit] :windows: butterfly lock_as_rwlock"
Expand All @@ -411,13 +411,13 @@ steps:
agents:
queue: 'default-windows-privileged'
# TODO: enable once we've figured out why this fails in docker
# plugins:
# docker#v3.2.0:
# image: "chefes/buildkite-windows"
# shell: [ "powershell", "-Command" ]
# always-pull: true
# propagate-environment: true
timeout_in_minutes: 20
plugins:
docker#v3.2.0:
image: "chefes/buildkite-windows"
shell: [ "powershell", "-Command" ]
always-pull: true
propagate-environment: true
timeout_in_minutes: 25
retry:
automatic:
limit: 1
Expand All @@ -435,7 +435,7 @@ steps:
shell: [ "powershell", "-Command" ]
always-pull: true
propagate-environment: true
timeout_in_minutes: 20
timeout_in_minutes: 25
soft_fail: true

- label: "[unit] :windows: common"
Expand All @@ -449,7 +449,7 @@ steps:
shell: [ "powershell", "-Command" ]
always-pull: true
propagate-environment: true
timeout_in_minutes: 20
timeout_in_minutes: 25
retry:
automatic:
limit: 1
Expand All @@ -460,12 +460,12 @@ steps:
agents:
queue: 'default-windows-privileged'
# TODO: enable once we've figured out why this fails in docker
# plugins:
# docker#v3.2.0:
# image: "chefes/buildkite-windows"
# shell: [ "powershell", "-Command" ]
# always-pull: true
# propagate-environment: true
plugins:
docker#v3.2.0:
image: "chefes/buildkite-windows"
shell: [ "powershell", "-Command" ]
always-pull: true
propagate-environment: true
timeout_in_minutes: 20
retry:
automatic:
Expand All @@ -477,12 +477,12 @@ steps:
agents:
queue: 'default-windows-privileged'
# TODO: enable once we've figured out why this fails in docker
# plugins:
# docker#v3.2.0:
# image: "chefes/buildkite-windows"
# shell: [ "powershell", "-Command" ]
# always-pull: true
# propagate-environment: true
plugins:
docker#v3.2.0:
image: "chefes/buildkite-windows"
shell: [ "powershell", "-Command" ]
always-pull: true
propagate-environment: true
timeout_in_minutes: 20
retry:
automatic:
Expand Down Expand Up @@ -639,12 +639,12 @@ steps:
agents:
queue: 'default-windows-privileged'
# TODO: enable once we've figured out why this fails in docker
# plugins:
# docker#v3.2.0:
# image: "chefes/buildkite-windows"
# shell: [ "powershell", "-Command" ]
# always-pull: true
# propagate-environment: true
plugins:
docker#v3.2.0:
image: "chefes/buildkite-windows"
shell: [ "powershell", "-Command" ]
always-pull: true
propagate-environment: true
timeout_in_minutes: 20
retry:
automatic:
Expand All @@ -656,12 +656,12 @@ steps:
agents:
queue: 'default-windows-privileged'
# TODO: enable once we've figured out why this fails in docker
# plugins:
# docker#v3.2.0:
# image: "chefes/buildkite-windows"
# shell: [ "powershell", "-Command" ]
# always-pull: true
# propagate-environment: true
plugins:
docker#v3.2.0:
image: "chefes/buildkite-windows"
shell: [ "powershell", "-Command" ]
always-pull: true
propagate-environment: true
timeout_in_minutes: 5
retry:
automatic:
Expand Down
25 changes: 12 additions & 13 deletions components/core/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,10 @@ impl<'a> SvcDir<'a> {
/// ```
/// use habitat_core::fs::find_command;
/// use std::{env,
/// fs};
/// path::PathBuf};
///
/// let first_path = fs::canonicalize("./tests/fixtures").unwrap();
/// let second_path = fs::canonicalize("./tests/fixtures/bin").unwrap();
/// let first_path = PathBuf::from("tests/fixtures");
/// let second_path = PathBuf::from("tests/fixtures/bin");
/// let path_bufs = vec![first_path, second_path];
/// let new_path = env::join_paths(path_bufs).unwrap();
/// env::set_var("PATH", &new_path);
Expand All @@ -467,10 +467,10 @@ impl<'a> SvcDir<'a> {
/// ```
/// use habitat_core::fs::find_command;
/// use std::{env,
/// fs};
/// path::PathBuf};
///
/// let first_path = fs::canonicalize("./tests/fixtures").unwrap();
/// let second_path = fs::canonicalize("./tests/fixtures/bin").unwrap();
/// let first_path = PathBuf::from("tests/fixtures");
/// let second_path = PathBuf::from("tests/fixtures/bin");
/// let path_bufs = vec![first_path, second_path];
/// let new_path = env::join_paths(path_bufs).unwrap();
/// env::set_var("PATH", &new_path);
Expand Down Expand Up @@ -803,7 +803,6 @@ mod test_find_command {

pub use super::find_command;
use std::{env,
fs,
path::PathBuf};

#[allow(dead_code)]
Expand All @@ -822,8 +821,8 @@ mod test_find_command {
fn setup_path() {
let orig_path = env::var_os("PATH").unwrap();
let mut os_paths: Vec<PathBuf> = env::split_paths(&orig_path).collect();
let first_path = fs::canonicalize("./tests/fixtures").unwrap();
let second_path = fs::canonicalize("./tests/fixtures/bin").unwrap();
let first_path = PathBuf::from("tests/fixtures");
let second_path = PathBuf::from("tests/fixtures/bin");
let mut path_bufs = vec![first_path, second_path];
path_bufs.append(&mut os_paths);
let new_path = env::join_paths(path_bufs).unwrap();
Expand Down Expand Up @@ -869,7 +868,7 @@ mod test_find_command {
mod argument_with_extension {
use super::{find_command,
setup_environment};
use std::fs::canonicalize;
use std::path::PathBuf;

#[test]
fn command_exists() {
Expand All @@ -895,7 +894,7 @@ mod test_find_command {
#[test]
fn first_command_on_path_found() {
setup_environment();
let target_path = canonicalize("./tests/fixtures/plan.sh").unwrap();
let target_path = PathBuf::from("tests/fixtures/plan.sh");
let result = find_command("plan.sh");
let found_path = result.unwrap();
assert_eq!(found_path, target_path);
Expand Down Expand Up @@ -952,7 +951,7 @@ mod test_find_command {
mod argument_with_extension {
use super::{find_command,
setup_environment};
use std::fs::canonicalize;
use std::path::PathBuf;

#[test]
fn command_exists() {
Expand All @@ -978,7 +977,7 @@ mod test_find_command {
#[test]
fn first_command_on_path_found() {
setup_environment();
let target_path = canonicalize("./tests/fixtures/plan.sh").unwrap();
let target_path = PathBuf::from("tests/fixtures/plan.sh");
let result = find_command("plan.sh");
let found_path = result.unwrap();
assert_eq!(found_path, target_path);
Expand Down
16 changes: 16 additions & 0 deletions components/hab/src/command/bldr/job/promote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ pub fn start(ui: &mut UI,

#[cfg(test)]
mod test {
#[cfg(windows)]
use std::fs::{self,
File};
use std::{env,
io::{self,
Cursor,
Expand Down Expand Up @@ -240,12 +243,25 @@ mod test {
"Properly formated timestamp".to_string(),
project_name: "Test Project".to_string(),
target: "x86_64-linux".to_string(), };

#[cfg(windows)]
let tmp_file_path = {
let mut t = env::temp_dir();
t.push("type.bat");
let mut tmp_file = File::create(&t).unwrap();
write!(tmp_file, "{}", "@echo off\ntype %*").unwrap();
env::set_var("EDITOR", &t);
t
};
#[cfg(unix)]
env::set_var("EDITOR", "cat");

let ident_list =
get_ident_list(&mut ui, &group_status, Some("core"), true).expect("Error fetching \
ident list");

#[cfg(windows)]
fs::remove_file(tmp_file_path).unwrap();
assert_eq!(ident_list,
["core/project1/1.0.0/20180101000000",
"core/project2/1.0.0/20180101000000",])
Expand Down
7 changes: 4 additions & 3 deletions components/sup-protocol/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ fn generate_protocols() {
.expect("protocols");
compile_proto_impls(&protocol_files(), &protocol_includes()).expect("protocol-impls");
for file in generated_files() {
fs::rename(&file,
format!("src/generated/{}",
file.file_name().unwrap().to_string_lossy())).unwrap();
fs::copy(&file,
format!("src/generated/{}",
file.file_name().unwrap().to_string_lossy())).unwrap();
fs::remove_file(&file).unwrap();
}
}

Expand Down
5 changes: 1 addition & 4 deletions support/ci/shared.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function Install-Rustup($Toolchain) {
}

function Install-RustToolchain($Toolchain) {
rustup set default-host x86_64-pc-windows-msvc
rustup component list --toolchain $toolchain | Out-Null
if ($LASTEXITCODE -ne 0) {
Write-Host "Installing rust toolchain $toolchain"
Expand Down Expand Up @@ -141,10 +142,6 @@ function Setup-Environment {

# On buildkite, the rust binaries will be directly in C:
if($env:BUILDKITE) {
$env:CARGO_HOME="C:\rust\.cargo"
$env:path = New-PathString -StartingPath $env:path -Path "C:\rust\.cargo\bin"
# this will avoid a path length limit from the long buildkite working dir path
$env:CARGO_TARGET_DIR = "c:\target"
$env:RUSTUP_HOME="C:\rust\.rustup"
$env:path = New-PathString -StartingPath $env:path -Path "C:\rust\.rustup\bin"
}
8 changes: 8 additions & 0 deletions test/run_studio_test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ param (

$ErrorActionPreference="stop"

. $PSScriptRoot\..\support\ci\shared.ps1
Install-Habitat

if(!(Get-PackageProvider -Name nuget -ErrorAction SilentlyContinue -ListAvailable)) {
Write-Host "Installing Nuget provider..."
Install-PackageProvider -Name NuGet -Force | Out-Null
}

if(!(Get-Module Await -ListAvailable)) {
Write-Host "Installing Await PS Module..."
Install-Module Await -Force | Out-Null
Expand Down

0 comments on commit a7c7708

Please sign in to comment.