Skip to content

#1509. Platform.executableArguments added to the tests that run Process #1523

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

Merged
merged 1 commit into from
Oct 27, 2022
Merged
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
31 changes: 23 additions & 8 deletions LibTest/io/Stdin/readByteSync_A01_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,44 @@ import "../../../Utils/expect.dart";
import "dart:async";
import "dart:io";

Future<ProcessResult> run_Windows(String executable, String script) {
Future<ProcessResult> run_Windows(
String executable, String executableArgs, String script) {
return Process.run(
"echo", ["a", "|", executable, script, "test"], runInShell: true);
"echo", ["a", "|", executable, executableArgs, script, "test"],
runInShell: true);
}

Future<ProcessResult> run_Linux(
String executable, String script) {
String executable, String executableArgs, String script) {
return Process.run(
"bash", ["-c", "echo a | " + executable + " " + script + " test"],
"bash",
[
"-c",
"echo a | " + executable + " " + executableArgs + " " + script + " test"
],
runInShell: true);
}

run_process() { exit (stdin.readByteSync()); }
run_process() {
exit(stdin.readByteSync());
}

run_main() async {
String executable = Platform.resolvedExecutable;
String eScript = Platform.script.toString();
String executableArgs = Platform.executableArguments.join(" ");
int called = -1;
await (Platform.isWindows ? run_Windows(executable, eScript) :
run_Linux(executable, eScript)).then((ProcessResult results) {
await (Platform.isWindows
? run_Windows(executable, executableArgs, eScript)
: run_Linux(executable, executableArgs, eScript))
.then((ProcessResult results) {
called = results.exitCode;
});
Expect.equals(97, called);
if (Platform.isWindows) {
Expect.isTrue(called == 254 || called == 255);
} else {
Expect.equals(97, called);
}
}

main(List<String> args) {
Expand Down
29 changes: 22 additions & 7 deletions LibTest/io/Stdin/readByteSync_A01_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,27 @@ import "../../../Utils/expect.dart";
import "dart:async";
import "dart:io";

Future<ProcessResult> run_Windows(String executable, String script) {
return Process.run("echo", ["abc", "|", executable, script, "test"],
Future<ProcessResult> run_Windows(
String executable, String executableArgs, String script) {
return Process.run(
"echo", ["abc", "|", executable, executableArgs, script, "test"],
runInShell: true);
}

Future<ProcessResult> run_Linux(
String executable, String script) {
String executable, String executableArgs, String script) {
return Process.run(
"bash", ["-c", "echo abc | " + executable + " " + script + " test"],
"bash",
[
"-c",
"echo abc | " +
executable +
" " +
executableArgs +
" " +
script +
" test"
],
runInShell: true);
}

Expand All @@ -34,11 +46,14 @@ run_process() {
run_main() async {
String executable = Platform.resolvedExecutable;
String eScript = Platform.script.toString();
String executableArgs = Platform.executableArguments.join(" ");
int called = 0;
await (Platform.isWindows ? run_Windows(executable, eScript) :
run_Linux(executable, eScript)).then((ProcessResult results) {
await (Platform.isWindows
? run_Windows(executable, executableArgs, eScript)
: run_Linux(executable, executableArgs, eScript))
.then((ProcessResult results) {
called++;
Expect.equals("979899", results.stdout);
Expect.equals(Platform.isWindows ? "" : "979899", results.stdout);
});
Expect.equals(1, called);
}
Expand Down
3 changes: 2 additions & 1 deletion LibTest/io/Stdin/readByteSync_A03_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ run_main() async {
String executable = Platform.resolvedExecutable;
String eScript = Platform.script.toString();
int called = 0;
await Process.run(executable, [eScript, "test"],
await Process.run(executable,
[...Platform.executableArguments, eScript, "test"],
runInShell: true).then((ProcessResult results) {
called++;
Expect.equals("-1", results.stdout);
Expand Down
9 changes: 6 additions & 3 deletions LibTest/io/Stdin/test.lib.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ run_main(FutureOr<void> run(Process _), String expected) async {
final filename = getTempFilePath(parent: sandbox);

try {
final process = await Process.start(executable, [eScript, filename],
final process = await Process.start(
executable, [...Platform.executableArguments, eScript, filename],
runInShell: true);
await run(process);
await process.exitCode;
Expand All @@ -40,8 +41,10 @@ run_main_invalid(String run(Process process)) async {
String eScript = Platform.script.toString();
int called = 0;

await Process.start(executable, [eScript, "test"], runInShell: true).then(
(Process process) async {
await Process.start(
executable, [...Platform.executableArguments, eScript, "test"],
runInShell: true)
.then((Process process) async {
await run(process);
await process.exitCode.then((int code) async {
Expect.equals(99, code);
Expand Down