Skip to content

Commit a7c7708

Browse files
committed
make all tests windows docker friendly
Signed-off-by: mwrock <[email protected]>
1 parent ee7497d commit a7c7708

File tree

6 files changed

+75
-54
lines changed

6 files changed

+75
-54
lines changed

.expeditor/verify.pipeline.yml

+34-34
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ steps:
402402
shell: [ "powershell", "-Command" ]
403403
always-pull: true
404404
propagate-environment: true
405-
timeout_in_minutes: 20
405+
timeout_in_minutes: 25
406406
soft_fail: true
407407

408408
- label: "[unit] :windows: butterfly lock_as_rwlock"
@@ -411,13 +411,13 @@ steps:
411411
agents:
412412
queue: 'default-windows-privileged'
413413
# TODO: enable once we've figured out why this fails in docker
414-
# plugins:
415-
# docker#v3.2.0:
416-
# image: "chefes/buildkite-windows"
417-
# shell: [ "powershell", "-Command" ]
418-
# always-pull: true
419-
# propagate-environment: true
420-
timeout_in_minutes: 20
414+
plugins:
415+
docker#v3.2.0:
416+
image: "chefes/buildkite-windows"
417+
shell: [ "powershell", "-Command" ]
418+
always-pull: true
419+
propagate-environment: true
420+
timeout_in_minutes: 25
421421
retry:
422422
automatic:
423423
limit: 1
@@ -435,7 +435,7 @@ steps:
435435
shell: [ "powershell", "-Command" ]
436436
always-pull: true
437437
propagate-environment: true
438-
timeout_in_minutes: 20
438+
timeout_in_minutes: 25
439439
soft_fail: true
440440

441441
- label: "[unit] :windows: common"
@@ -449,7 +449,7 @@ steps:
449449
shell: [ "powershell", "-Command" ]
450450
always-pull: true
451451
propagate-environment: true
452-
timeout_in_minutes: 20
452+
timeout_in_minutes: 25
453453
retry:
454454
automatic:
455455
limit: 1
@@ -460,12 +460,12 @@ steps:
460460
agents:
461461
queue: 'default-windows-privileged'
462462
# TODO: enable once we've figured out why this fails in docker
463-
# plugins:
464-
# docker#v3.2.0:
465-
# image: "chefes/buildkite-windows"
466-
# shell: [ "powershell", "-Command" ]
467-
# always-pull: true
468-
# propagate-environment: true
463+
plugins:
464+
docker#v3.2.0:
465+
image: "chefes/buildkite-windows"
466+
shell: [ "powershell", "-Command" ]
467+
always-pull: true
468+
propagate-environment: true
469469
timeout_in_minutes: 20
470470
retry:
471471
automatic:
@@ -477,12 +477,12 @@ steps:
477477
agents:
478478
queue: 'default-windows-privileged'
479479
# TODO: enable once we've figured out why this fails in docker
480-
# plugins:
481-
# docker#v3.2.0:
482-
# image: "chefes/buildkite-windows"
483-
# shell: [ "powershell", "-Command" ]
484-
# always-pull: true
485-
# propagate-environment: true
480+
plugins:
481+
docker#v3.2.0:
482+
image: "chefes/buildkite-windows"
483+
shell: [ "powershell", "-Command" ]
484+
always-pull: true
485+
propagate-environment: true
486486
timeout_in_minutes: 20
487487
retry:
488488
automatic:
@@ -639,12 +639,12 @@ steps:
639639
agents:
640640
queue: 'default-windows-privileged'
641641
# TODO: enable once we've figured out why this fails in docker
642-
# plugins:
643-
# docker#v3.2.0:
644-
# image: "chefes/buildkite-windows"
645-
# shell: [ "powershell", "-Command" ]
646-
# always-pull: true
647-
# propagate-environment: true
642+
plugins:
643+
docker#v3.2.0:
644+
image: "chefes/buildkite-windows"
645+
shell: [ "powershell", "-Command" ]
646+
always-pull: true
647+
propagate-environment: true
648648
timeout_in_minutes: 20
649649
retry:
650650
automatic:
@@ -656,12 +656,12 @@ steps:
656656
agents:
657657
queue: 'default-windows-privileged'
658658
# TODO: enable once we've figured out why this fails in docker
659-
# plugins:
660-
# docker#v3.2.0:
661-
# image: "chefes/buildkite-windows"
662-
# shell: [ "powershell", "-Command" ]
663-
# always-pull: true
664-
# propagate-environment: true
659+
plugins:
660+
docker#v3.2.0:
661+
image: "chefes/buildkite-windows"
662+
shell: [ "powershell", "-Command" ]
663+
always-pull: true
664+
propagate-environment: true
665665
timeout_in_minutes: 5
666666
retry:
667667
automatic:

components/core/src/fs.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,10 @@ impl<'a> SvcDir<'a> {
450450
/// ```
451451
/// use habitat_core::fs::find_command;
452452
/// use std::{env,
453-
/// fs};
453+
/// path::PathBuf};
454454
///
455-
/// let first_path = fs::canonicalize("./tests/fixtures").unwrap();
456-
/// let second_path = fs::canonicalize("./tests/fixtures/bin").unwrap();
455+
/// let first_path = PathBuf::from("tests/fixtures");
456+
/// let second_path = PathBuf::from("tests/fixtures/bin");
457457
/// let path_bufs = vec![first_path, second_path];
458458
/// let new_path = env::join_paths(path_bufs).unwrap();
459459
/// env::set_var("PATH", &new_path);
@@ -467,10 +467,10 @@ impl<'a> SvcDir<'a> {
467467
/// ```
468468
/// use habitat_core::fs::find_command;
469469
/// use std::{env,
470-
/// fs};
470+
/// path::PathBuf};
471471
///
472-
/// let first_path = fs::canonicalize("./tests/fixtures").unwrap();
473-
/// let second_path = fs::canonicalize("./tests/fixtures/bin").unwrap();
472+
/// let first_path = PathBuf::from("tests/fixtures");
473+
/// let second_path = PathBuf::from("tests/fixtures/bin");
474474
/// let path_bufs = vec![first_path, second_path];
475475
/// let new_path = env::join_paths(path_bufs).unwrap();
476476
/// env::set_var("PATH", &new_path);
@@ -803,7 +803,6 @@ mod test_find_command {
803803

804804
pub use super::find_command;
805805
use std::{env,
806-
fs,
807806
path::PathBuf};
808807

809808
#[allow(dead_code)]
@@ -822,8 +821,8 @@ mod test_find_command {
822821
fn setup_path() {
823822
let orig_path = env::var_os("PATH").unwrap();
824823
let mut os_paths: Vec<PathBuf> = env::split_paths(&orig_path).collect();
825-
let first_path = fs::canonicalize("./tests/fixtures").unwrap();
826-
let second_path = fs::canonicalize("./tests/fixtures/bin").unwrap();
824+
let first_path = PathBuf::from("tests/fixtures");
825+
let second_path = PathBuf::from("tests/fixtures/bin");
827826
let mut path_bufs = vec![first_path, second_path];
828827
path_bufs.append(&mut os_paths);
829828
let new_path = env::join_paths(path_bufs).unwrap();
@@ -869,7 +868,7 @@ mod test_find_command {
869868
mod argument_with_extension {
870869
use super::{find_command,
871870
setup_environment};
872-
use std::fs::canonicalize;
871+
use std::path::PathBuf;
873872

874873
#[test]
875874
fn command_exists() {
@@ -895,7 +894,7 @@ mod test_find_command {
895894
#[test]
896895
fn first_command_on_path_found() {
897896
setup_environment();
898-
let target_path = canonicalize("./tests/fixtures/plan.sh").unwrap();
897+
let target_path = PathBuf::from("tests/fixtures/plan.sh");
899898
let result = find_command("plan.sh");
900899
let found_path = result.unwrap();
901900
assert_eq!(found_path, target_path);
@@ -952,7 +951,7 @@ mod test_find_command {
952951
mod argument_with_extension {
953952
use super::{find_command,
954953
setup_environment};
955-
use std::fs::canonicalize;
954+
use std::path::PathBuf;
956955

957956
#[test]
958957
fn command_exists() {
@@ -978,7 +977,7 @@ mod test_find_command {
978977
#[test]
979978
fn first_command_on_path_found() {
980979
setup_environment();
981-
let target_path = canonicalize("./tests/fixtures/plan.sh").unwrap();
980+
let target_path = PathBuf::from("tests/fixtures/plan.sh");
982981
let result = find_command("plan.sh");
983982
let found_path = result.unwrap();
984983
assert_eq!(found_path, target_path);

components/hab/src/command/bldr/job/promote.rs

+16
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ pub fn start(ui: &mut UI,
142142

143143
#[cfg(test)]
144144
mod test {
145+
#[cfg(windows)]
146+
use std::fs::{self,
147+
File};
145148
use std::{env,
146149
io::{self,
147150
Cursor,
@@ -240,12 +243,25 @@ mod test {
240243
"Properly formated timestamp".to_string(),
241244
project_name: "Test Project".to_string(),
242245
target: "x86_64-linux".to_string(), };
246+
247+
#[cfg(windows)]
248+
let tmp_file_path = {
249+
let mut t = env::temp_dir();
250+
t.push("type.bat");
251+
let mut tmp_file = File::create(&t).unwrap();
252+
write!(tmp_file, "{}", "@echo off\ntype %*").unwrap();
253+
env::set_var("EDITOR", &t);
254+
t
255+
};
256+
#[cfg(unix)]
243257
env::set_var("EDITOR", "cat");
244258

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

263+
#[cfg(windows)]
264+
fs::remove_file(tmp_file_path).unwrap();
249265
assert_eq!(ident_list,
250266
["core/project1/1.0.0/20180101000000",
251267
"core/project2/1.0.0/20180101000000",])

components/sup-protocol/build.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ fn generate_protocols() {
3838
.expect("protocols");
3939
compile_proto_impls(&protocol_files(), &protocol_includes()).expect("protocol-impls");
4040
for file in generated_files() {
41-
fs::rename(&file,
42-
format!("src/generated/{}",
43-
file.file_name().unwrap().to_string_lossy())).unwrap();
41+
fs::copy(&file,
42+
format!("src/generated/{}",
43+
file.file_name().unwrap().to_string_lossy())).unwrap();
44+
fs::remove_file(&file).unwrap();
4445
}
4546
}
4647

support/ci/shared.ps1

+1-4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function Install-Rustup($Toolchain) {
2929
}
3030

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

142143
# On buildkite, the rust binaries will be directly in C:
143144
if($env:BUILDKITE) {
144-
$env:CARGO_HOME="C:\rust\.cargo"
145-
$env:path = New-PathString -StartingPath $env:path -Path "C:\rust\.cargo\bin"
146145
# this will avoid a path length limit from the long buildkite working dir path
147146
$env:CARGO_TARGET_DIR = "c:\target"
148-
$env:RUSTUP_HOME="C:\rust\.rustup"
149-
$env:path = New-PathString -StartingPath $env:path -Path "C:\rust\.rustup\bin"
150147
}

test/run_studio_test.ps1

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ param (
66

77
$ErrorActionPreference="stop"
88

9+
. $PSScriptRoot\..\support\ci\shared.ps1
10+
Install-Habitat
11+
12+
if(!(Get-PackageProvider -Name nuget -ErrorAction SilentlyContinue -ListAvailable)) {
13+
Write-Host "Installing Nuget provider..."
14+
Install-PackageProvider -Name NuGet -Force | Out-Null
15+
}
16+
917
if(!(Get-Module Await -ListAvailable)) {
1018
Write-Host "Installing Await PS Module..."
1119
Install-Module Await -Force | Out-Null

0 commit comments

Comments
 (0)