Skip to content

Commit

Permalink
make clippy and all tests windows docker friendly
Browse files Browse the repository at this point in the history
Signed-off-by: mwrock <[email protected]>
  • Loading branch information
mwrock committed Jun 5, 2019
1 parent ee7497d commit 4c0401e
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 91 deletions.
95 changes: 46 additions & 49 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ steps:
- .\test\run_clippy.ps1 stable .\test\unexamined_lints.txt .\test\allowed_lints.txt .\test\lints_to_fix.txt .\test\denied_lints.txt
agents:
queue: 'default-windows-privileged'
# 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: 25

#######################################################################
Expand Down Expand Up @@ -402,22 +402,21 @@ 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"
command:
- ./test/run_cargo_test.ps1 butterfly -Nightly -Features "lock_as_rwlock deadlock_detection" -TestOptions "--test-threads=1"
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: 40
retry:
automatic:
limit: 1
Expand All @@ -435,7 +434,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 +448,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 @@ -459,13 +458,12 @@ steps:
- ./test/run_cargo_test.ps1 core
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 @@ -476,14 +474,13 @@ steps:
- ./test/run_cargo_test.ps1 hab
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 Down Expand Up @@ -515,7 +512,7 @@ steps:
shell: [ "powershell", "-Command" ]
always-pull: true
propagate-environment: true
timeout_in_minutes: 10
timeout_in_minutes: 20
retry:
automatic:
limit: 1
Expand All @@ -531,7 +528,7 @@ steps:
shell: [ "powershell", "-Command" ]
always-pull: true
propagate-environment: true
timeout_in_minutes: 10
timeout_in_minutes: 20
retry:
automatic:
limit: 1
Expand All @@ -547,7 +544,7 @@ steps:
shell: [ "powershell", "-Command" ]
always-pull: true
propagate-environment: true
timeout_in_minutes: 20
timeout_in_minutes: 25
retry:
automatic:
limit: 1
Expand Down Expand Up @@ -638,13 +635,12 @@ steps:
- ./test/run_cargo_test.ps1 sup-protocol
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 @@ -655,13 +651,12 @@ steps:
- ./test/run_studio_test.ps1 "studio-from-source"
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 Expand Up @@ -872,6 +867,7 @@ steps:
shell: [ "powershell", "-Command" ]
always-pull: true
propagate-environment: true
timeout_in_minutes: 40
retry:
automatic:
limit: 1
Expand Down Expand Up @@ -926,6 +922,7 @@ steps:
shell: [ "powershell", "-Command" ]
always-pull: true
propagate-environment: true
timeout_in_minutes: 40
retry:
automatic:
limit: 1
Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function Invoke-Build([string]$Path, [switch]$Clean, [string]$Command, [switch]$
Install-RustToolchain $toolchain
rustup component add --toolchain $Toolchain rustfmt
Setup-Environment
Invoke-Expression "cargo +$ToolChain $Command --all -- --check"
Invoke-Expression "cargo +$ToolChain $Command --all"
break
}
"clippy" {
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
21 changes: 0 additions & 21 deletions components/hab/src/command/bldr/job/promote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,25 +229,4 @@ mod test {
["core/project1/1.0.0/20180101000000",
"core/project2/1.0.0/20180101000000",])
}

#[test]
fn test_get_ident_list_interactive() {
let (mut ui, _stdout, _stderr) = ui();
let group_status = SchedulerResponse { id: "12345678".to_string(),
state: "Finished".to_string(),
projects: sample_project_list(),
created_at:
"Properly formated timestamp".to_string(),
project_name: "Test Project".to_string(),
target: "x86_64-linux".to_string(), };
env::set_var("EDITOR", "cat");

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

assert_eq!(ident_list,
["core/project1/1.0.0/20180101000000",
"core/project2/1.0.0/20180101000000",])
}
}
8 changes: 5 additions & 3 deletions components/sup-protocol/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ 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())).expect("unable to copy \
generated file");
fs::remove_file(&file).unwrap();
}
}

Expand Down
6 changes: 2 additions & 4 deletions support/ci/shared.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ function Install-Rustup($Toolchain) {

if (get-command -Name rustup.exe -ErrorAction SilentlyContinue) {
Write-Host "rustup is currently installed"
rustup set default-host x86_64-pc-windows-msvc
rustup default stable-x86_64-pc-windows-msvc
} else {
Write-Host "Installing rustup and $toolchain-x86_64-pc-windows-msvc Rust."
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Expand Down Expand Up @@ -141,10 +143,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 4c0401e

Please sign in to comment.