Skip to content

Commit 5ed2aeb

Browse files
authored
Merge pull request #401 from ebarnard/windows-min-ci
Run the `Minimum Rust` CI job on Windows and fix it on Linux
2 parents 0409188 + 9dcf641 commit 5ed2aeb

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

azure-pipelines.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,24 @@ trigger:
22
- master
33

44
jobs:
5-
- job: min
6-
displayName: Minimum Rust
5+
- job: min_linux
6+
pool:
7+
vmImage: ubuntu-16.04
8+
displayName: Minimum Rust (Linux)
9+
variables:
10+
TOOLCHAIN: 1.16.0
11+
steps:
12+
- template: ci/azure-install-rust.yml
13+
- script: cargo build
14+
15+
- job: min_Windows
16+
pool:
17+
vmImage: vs2017-win2016
18+
displayName: Minimum Rust (Windows)
19+
variables:
20+
TOOLCHAIN: 1.16.0
721
steps:
822
- template: ci/azure-install-rust.yml
9-
parameters:
10-
toolchain: 1.16.0
1123
- script: cargo build
1224

1325
- job: Linux

ci/azure-install-rust.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ steps:
1111
condition: ne( variables['Agent.OS'], 'Windows_NT' )
1212
1313
- script: |
14+
IF "%TOOLCHAIN%"=="" (SET TOOLCHAIN=stable-%TARGET%)
1415
curl -sSf -o rustup-init.exe https://win.rustup.rs
15-
rustup-init.exe -y --default-toolchain stable-%TARGET%
16+
rustup-init.exe -y --default-toolchain %TOOLCHAIN%
1617
echo ##vso[task.prependpath]%USERPROFILE%\.cargo\bin
1718
displayName: Install rust (windows)
1819
condition: eq( variables['Agent.OS'], 'Windows_NT' )

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2401,7 +2401,7 @@ fn spawn(cmd: &mut Command, program: &str) -> Result<(Child, JoinHandle<()>), Er
24012401
}
24022402

24032403
fn fail(s: &str) -> ! {
2404-
eprintln!("\n\nerror occurred: {}\n\n", s);
2404+
let _ = writeln!(io::stderr(), "\n\nerror occurred: {}\n\n", s);
24052405
std::process::exit(1);
24062406
}
24072407

src/windows_registry.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,18 +225,18 @@ mod impl_ {
225225
return Box::new(iter::empty());
226226
};
227227
Box::new(instances.filter_map(|instance| {
228-
let instance = instance.ok()?;
229-
let installation_name = instance.installation_name().ok()?;
230-
if installation_name.to_str()?.starts_with("VisualStudio/16.") {
231-
Some(PathBuf::from(instance.installation_path().ok()?))
228+
let instance = otry!(instance.ok());
229+
let installation_name = otry!(instance.installation_name().ok());
230+
if otry!(installation_name.to_str()).starts_with("VisualStudio/16.") {
231+
Some(PathBuf::from(otry!(instance.installation_path().ok())))
232232
} else {
233233
None
234234
}
235235
}))
236236
}
237237

238238
fn find_tool_in_vs16_path(tool: &str, target: &str) -> Option<Tool> {
239-
vs16_instances().find_map(|path| {
239+
vs16_instances().filter_map(|path| {
240240
let path = path.join(tool);
241241
if !path.is_file() {
242242
return None;
@@ -246,7 +246,7 @@ mod impl_ {
246246
tool.env.push(("Platform".into(), "X64".into()));
247247
}
248248
Some(tool)
249-
})
249+
}).next()
250250
}
251251

252252
fn find_msbuild_vs16(target: &str) -> Option<Tool> {
@@ -307,7 +307,7 @@ mod impl_ {
307307
.ok()
308308
.and_then(|key| key.query_str("15.0").ok())
309309
.map(|path| PathBuf::from(path).join(tool))
310-
.filter(|ref path| path.is_file());
310+
.and_then(|path| if path.is_file() { Some(path) } else { None });
311311
}
312312

313313
path.map(|path| {
@@ -681,7 +681,7 @@ mod impl_ {
681681
for subkey in key.iter().filter_map(|k| k.ok()) {
682682
let val = subkey
683683
.to_str()
684-
.and_then(|s| s.trim_start_matches("v").replace(".", "").parse().ok());
684+
.and_then(|s| s.trim_left_matches("v").replace(".", "").parse().ok());
685685
let val = match val {
686686
Some(s) => s,
687687
None => continue,

0 commit comments

Comments
 (0)