File tests/misc/background.c changed (mode: 100644) (index 6978e1a53..db27be9b9) |
3 |
3 |
#include <unistd.h> /* chdir() usleep() */ |
#include <unistd.h> /* chdir() usleep() */ |
4 |
4 |
|
|
5 |
5 |
#include <stdio.h> /* FILE fclose() fputs() */ |
#include <stdio.h> /* FILE fclose() fputs() */ |
|
6 |
|
#include <stdlib.h> /* free() */ |
|
7 |
|
#include <string.h> /* strdup() */ |
6 |
8 |
|
|
7 |
9 |
#include <test-utils.h> |
#include <test-utils.h> |
8 |
10 |
|
|
|
10 |
12 |
#include "../../src/engine/var.h" |
#include "../../src/engine/var.h" |
11 |
13 |
#include "../../src/engine/variables.h" |
#include "../../src/engine/variables.h" |
12 |
14 |
#include "../../src/utils/cancellation.h" |
#include "../../src/utils/cancellation.h" |
|
15 |
|
#include "../../src/utils/env.h" |
13 |
16 |
#include "../../src/utils/string_array.h" |
#include "../../src/utils/string_array.h" |
14 |
17 |
#include "../../src/ui/ui.h" |
#include "../../src/ui/ui.h" |
15 |
18 |
#include "../../src/background.h" |
#include "../../src/background.h" |
|
... |
... |
TEST(background_redirects_streams_properly, IF(not_windows)) |
267 |
270 |
assert_success(bg_and_wait_for_errors("echo a", &no_cancellation)); |
assert_success(bg_and_wait_for_errors("echo a", &no_cancellation)); |
268 |
271 |
} |
} |
269 |
272 |
|
|
|
273 |
|
TEST(can_run_command_starting_with_a_dash, IF(not_windows)) |
|
274 |
|
{ |
|
275 |
|
char sandbox[PATH_MAX + 1]; |
|
276 |
|
make_abs_path(sandbox, sizeof(sandbox), SANDBOX_PATH, "", /*cwd=*/NULL); |
|
277 |
|
|
|
278 |
|
create_executable(SANDBOX_PATH "/-script"); |
|
279 |
|
make_file(SANDBOX_PATH "/-script", "#!/bin/sh"); |
|
280 |
|
|
|
281 |
|
char *saved_path_env = strdup(env_get("PATH")); |
|
282 |
|
env_set("PATH", sandbox); |
|
283 |
|
|
|
284 |
|
assert_success(bg_and_wait_for_errors("-script", &no_cancellation)); |
|
285 |
|
|
|
286 |
|
env_set("PATH", saved_path_env); |
|
287 |
|
free(saved_path_env); |
|
288 |
|
|
|
289 |
|
remove_file(SANDBOX_PATH "/-script"); |
|
290 |
|
} |
|
291 |
|
|
270 |
292 |
static void |
static void |
271 |
293 |
task(bg_op_t *bg_op, void *arg) |
task(bg_op_t *bg_op, void *arg) |
272 |
294 |
{ |
{ |