Skip to content

Commit 487cd78

Browse files
authored
Merge pull request #171 from Mark-Simulacrum/test-is-run
Make "build" mean compilation and "test" mean execute.
2 parents b6ed6ba + bf2ccb8 commit 487cd78

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

src/ex_run.rs

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -176,39 +176,41 @@ fn verify_toolchains(config: &Experiment, tcs: &[Toolchain]) -> Result<()> {
176176
Ok(())
177177
}
178178

179-
fn test_build_and_test(
180-
ex: &Experiment,
181-
source_path: &Path,
182-
toolchain: &Toolchain,
183-
) -> Result<TestResult> {
184-
let build_r = toolchain.run_cargo(
185-
&ex.name,
186-
source_path,
187-
&["build", "--frozen"],
188-
CargoState::Locked,
189-
);
190-
let mut test_r;
191-
192-
if build_r.is_ok() {
193-
// First build, with --no-run
194-
test_r = Some(toolchain.run_cargo(
179+
fn build(ex: &Experiment, source_path: &Path, toolchain: &Toolchain) -> Result<()> {
180+
toolchain
181+
.run_cargo(
195182
&ex.name,
196183
source_path,
197-
&["test", "--frozen", "--no-run"],
184+
&["build", "--frozen"],
198185
CargoState::Locked,
199-
));
200-
// Then run
201-
test_r = test_r.map(|_| {
186+
)
187+
.map(|_| {
202188
toolchain.run_cargo(
203189
&ex.name,
204190
source_path,
205-
&["test", "--frozen"],
191+
&["test", "--frozen", "--no-run"],
206192
CargoState::Locked,
207193
)
208-
});
194+
})
195+
.map(|_| ())
196+
}
197+
198+
fn test_build_and_test(
199+
ex: &Experiment,
200+
source_path: &Path,
201+
toolchain: &Toolchain,
202+
) -> Result<TestResult> {
203+
let build_r = build(ex, source_path, toolchain);
204+
let test_r = if build_r.is_ok() {
205+
Some(toolchain.run_cargo(
206+
&ex.name,
207+
source_path,
208+
&["test", "--frozen"],
209+
CargoState::Locked,
210+
))
209211
} else {
210-
test_r = None;
211-
}
212+
None
213+
};
212214

213215
Ok(match (build_r, test_r) {
214216
(Err(_), None) => TestResult::BuildFail,
@@ -223,13 +225,7 @@ fn test_build_only(
223225
source_path: &Path,
224226
toolchain: &Toolchain,
225227
) -> Result<TestResult> {
226-
let r = toolchain.run_cargo(
227-
&ex.name,
228-
source_path,
229-
&["build", "--frozen"],
230-
CargoState::Locked,
231-
);
232-
228+
let r = build(ex, source_path, toolchain);
233229
if r.is_ok() {
234230
Ok(TestResult::TestPass)
235231
} else {

0 commit comments

Comments
 (0)