Fix output in parallel mode.

This commit is contained in:
jcamiel 2024-04-08 14:34:20 +02:00
parent 2227b91ee1
commit cd431d023a
No known key found for this signature in database
GPG Key ID: 07FF11CFD55356CC
5 changed files with 31 additions and 32 deletions

View File

@ -0,0 +1,11 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'
hurl --parallel --output NUL `
tests_ok/parallel_a.hurl `
tests_ok/parallel_b.hurl `
tests_ok/parallel_c.hurl `
tests_ok/parallel_d.hurl `
tests_ok/parallel_e.hurl `
tests_ok/parallel_f.hurl `
tests_ok/parallel_g.hurl

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -Eeuo pipefail
hurl --parallel --output /dev/null \
tests_ok/parallel_a.hurl \
tests_ok/parallel_b.hurl \
tests_ok/parallel_c.hurl \
tests_ok/parallel_d.hurl \
tests_ok/parallel_e.hurl \
tests_ok/parallel_f.hurl \
tests_ok/parallel_g.hurl

View File

@ -399,37 +399,7 @@ impl CliOptions {
let netrc_file = self.netrc_file.clone();
let netrc_optional = self.netrc_optional;
let no_proxy = self.no_proxy.clone();
// FIXME:
// When used globally (on the command line), `--output` writes the last successful request
// to `output` file. We don't want to output every entry's response, so we initialise
// output to `None`.
// The straightforward code should have been `let output = self.output;` but if we do this
// every entry's response would have been dumped to stdout.
//
// If we compare with `--compressed`:
//
// ```
// cli.compressed = true =>
// entry_1.compressed = true
// entry_2.compressed = true
// entry_2.overridden.compressed = false
// entry_3.compressed = true
// etc...
// entry_last.compressed = true
// ```
//
// whereas
//
// ```
// cli.output = /tmp/out.bin =>
// entry_1.output = None
// entry_2.output = None
// entry_2.overridden.output = /tmp/bar.bin
// entry_3.output = None
// etc...
// entry_last.output = /tmp/out.bin
// ```
let output = None;
let output = self.output.clone();
let path_as_is = self.path_as_is;
let post_entry = if self.interactive {
Some(cli::interactive::post_entry as fn() -> bool)

View File

@ -37,7 +37,14 @@ pub fn get_entry_options(
variables: &mut HashMap<String, Value>,
logger: &mut Logger,
) -> Result<RunnerOptions, Error> {
let mut runner_options = runner_options.clone();
let runner_options = runner_options.clone();
// When used globally (on the command line), `--output` writes the last successful request
// to `output` file. We don't want to output every entry's response, so we initialise
// output to `None`.
let mut runner_options = RunnerOptions {
output: None,
..runner_options
};
if !has_options(entry) {
return Ok(runner_options);
}