Skip to content

Divide test run between multiple travis builds. #39664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ matrix:
fast_finish: true
include:
# Linux builders, all docker images
- env: IMAGE=x86_64-gnu-llvm-3.7 ALLOW_PR=1 RUST_BACKTRACE=1 BOOTSTRAP_ARGS="--slice 0 --number-slices 4"
- env: IMAGE=x86_64-gnu-llvm-3.7 ALLOW_PR=1 RUST_BACKTRACE=1 BOOTSTRAP_ARGS="--slice 1 --number-slices 4"
- env: IMAGE=x86_64-gnu-llvm-3.7 ALLOW_PR=1 RUST_BACKTRACE=1 BOOTSTRAP_ARGS="--slice 2 --number-slices 4"
- env: IMAGE=x86_64-gnu-llvm-3.7 ALLOW_PR=1 RUST_BACKTRACE=1 BOOTSTRAP_ARGS="--slice 3 --number-slices 4"
- env: IMAGE=android DEPLOY=1
- env: IMAGE=armhf-gnu
- env: IMAGE=cross DEPLOY=1
Expand All @@ -33,7 +37,6 @@ matrix:
- env: IMAGE=x86_64-gnu-aux
- env: IMAGE=x86_64-gnu-debug
- env: IMAGE=x86_64-gnu-nopt
- env: IMAGE=x86_64-gnu-llvm-3.7 ALLOW_PR=1 RUST_BACKTRACE=1
- env: IMAGE=x86_64-gnu-distcheck
- env: IMAGE=x86_64-gnu-incremental

Expand Down
18 changes: 18 additions & 0 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub enum Subcommand {
Test {
paths: Vec<PathBuf>,
test_args: Vec<String>,
split: Option<(usize, usize)>,
},
Bench {
paths: Vec<PathBuf>,
Expand Down Expand Up @@ -224,10 +225,27 @@ To learn more about a subcommand, run `./x.py <command> -h`
}
"test" => {
opts.optmulti("", "test-args", "extra arguments", "ARGS");
opts.optopt("",
"number-slices",
"divide the test run in N segments",
"N");
opts.optopt("",
"slice",
"run ith segment",
"i");
m = parse(&opts);
let split = match (m.opt_str("slice"), m.opt_str("number-slices")) {
(Some(raw_slice), Some(raw_nb_slices)) => {
Some((raw_slice.parse().unwrap(),
raw_nb_slices.parse().unwrap()))
}
(None, None) => None,
_ => panic!("You must provide --slice and --number-slices"),
};
Subcommand::Test {
paths: remaining_as_path(&m),
test_args: m.opt_strs("test-args"),
split: split,
}
}
"bench" => {
Expand Down
28 changes: 24 additions & 4 deletions src/bootstrap/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

use std::collections::{HashMap, HashSet};
use std::mem;
use std::cmp::min;

use check::{self, TestKind};
use compile;
Expand Down Expand Up @@ -982,10 +983,14 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd?
// product of the two and then create a step based off them. Note that
// the stage each step is associated was specified with the `--step`
// flag on the command line.
let mut split = None;
let (kind, paths) = match self.build.flags.cmd {
Subcommand::Build { ref paths } => (Kind::Build, &paths[..]),
Subcommand::Doc { ref paths } => (Kind::Doc, &paths[..]),
Subcommand::Test { ref paths, test_args: _ } => (Kind::Test, &paths[..]),
Subcommand::Test { ref paths, test_args: _, split: new_split } => {
split = new_split;
(Kind::Test, &paths[..])
}
Subcommand::Bench { ref paths, test_args: _ } => (Kind::Bench, &paths[..]),
Subcommand::Dist { ref paths, install } => {
if install {
Expand All @@ -996,8 +1001,7 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd?
}
Subcommand::Clean => panic!(),
};

self.rules.values().filter(|rule| rule.kind == kind).filter(|rule| {
let steps = self.rules.values().filter(|rule| rule.kind == kind).filter(|rule| {
(paths.len() == 0 && rule.default) || paths.iter().any(|path| {
path.ends_with(rule.path)
})
Expand Down Expand Up @@ -1041,7 +1045,23 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd?
self.sbuild.name(rule.name).target(target).host(host)
})
})
}).collect()
}).collect::<Vec<_>>();

if let Some((offset, nb_split)) = split {
assert!(nb_split <= steps.len(),
"you asked for {} slices but there are only {} tasks",
nb_split,
steps.len());
let index = |i| {
i * (steps.len() / nb_split) + min(steps.len() % nb_split, i)
};
let from = index(offset);
let to = index(offset + 1);
steps[from..to].into()
} else {
steps
}

}

/// Execute all top-level targets indicated by `steps`.
Expand Down
8 changes: 4 additions & 4 deletions src/ci/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
Expand Down Expand Up @@ -67,7 +67,7 @@ fi
if [ ! -z "$SCRIPT" ]; then
sh -x -c "$SCRIPT"
else
make -j $ncpus tidy
make -j $ncpus
make $RUST_CHECK_TARGET -j $ncpus
time make -j $ncpus tidy
time make -j $ncpus
time make $RUST_CHECK_TARGET -j $ncpus
fi