Skip to content

Commit

Permalink
Issue #1094: changes from master moved to pre-nnbd for LibTests/io/Pr…
Browse files Browse the repository at this point in the history
…ocess
  • Loading branch information
iarkh committed Aug 4, 2021
1 parent 5958ecb commit a52287c
Show file tree
Hide file tree
Showing 29 changed files with 306 additions and 300 deletions.
27 changes: 0 additions & 27 deletions LibTest/io/Process/checkEnvironment_lib.dart

This file was deleted.

9 changes: 4 additions & 5 deletions LibTest/io/Process/exitCode_A01_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ String command;
List<String> args;

void setCommand() {
if (Platform.isLinux) {
command = 'sleep';
args = ['5'];
}
if (Platform.isWindows) {
command = 'ping';
args = ['127.0.0.1 -n 6 > nul'];
} else {
command = 'sleep';
args = ['5'];
}
}

Expand All @@ -58,7 +57,7 @@ main() {

process.exitCode.then((int value) {
if (Platform.isWindows) {
Expect.equals(1, value);
Expect.isTrue(value == 1 || value == -1);
} else if (Platform.isLinux || Platform.isMacOS) {
Expect.equals(-15, value);
}
Expand Down
7 changes: 3 additions & 4 deletions LibTest/io/Process/killPid_A01_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ String command;
List<String> args;

void setCommand() {
if (Platform.isLinux) {
command = 'sleep';
args = ['5'];
}
if (Platform.isWindows) {
command = 'ping';
args = ['127.0.0.1 -n 6 > nul'];
} else {
command = 'sleep';
args = ['5'];
}
}

Expand Down
7 changes: 3 additions & 4 deletions LibTest/io/Process/killPid_A01_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ String command;
List<String> args;

void setCommand() {
if (Platform.isLinux) {
command = 'sleep';
args = ['5'];
}
if (Platform.isWindows) {
command = 'ping';
args = ['127.0.0.1 -n 6 > nul'];
} else {
command = 'sleep';
args = ['5'];
}
}

Expand Down
7 changes: 3 additions & 4 deletions LibTest/io/Process/kill_A01_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ String command;
List<String> args;

void setCommand() {
if (Platform.isLinux) {
command = 'sleep';
args = ['5'];
}
if (Platform.isWindows) {
command = 'ping';
args = ['127.0.0.1 -n 6 > nul'];
} else {
command = 'sleep';
args = ['5'];
}
}

Expand Down
38 changes: 4 additions & 34 deletions LibTest/io/Process/kill_A01_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,49 +25,19 @@
/// completes with the exit code 0 when the process completes.
/// @author [email protected]
import 'dart:convert';
import "dart:io";
import "../../../Utils/expect.dart";

String command;
List<String> args;

void setCommand() {
if (Platform.isLinux) {
command = 'echo';
args = ['-start'];
}
if (Platform.isWindows) {
command = Platform.resolvedExecutable;
args = ['--version'];
}
}

main() {
setCommand();
String command = Platform.resolvedExecutable;
List<String> args = [...Platform.executableArguments, '--version'];
asyncStart();
Process.start(command, args).then((Process process) {

process.exitCode.then((int value) {
Expect.equals(0, value);
bool pKill = process.kill();
Expect.isFalse(pKill);
if (Platform.isWindows) {
asyncEnd();
}
Expect.equals(0, value);
asyncEnd();
});

if (!Platform.isWindows) {
process.stdout.toList().then((List outList) {
Utf8Decoder decode = new Utf8Decoder();
String decoded = decode.convert(outList[0]);
Expect.isTrue(decoded.contains("-start"));
}).then((_) {
process.stderr.toList().then((List errList) {
Expect.equals(0, errList.length);
asyncEnd();
});
});
}
});
}
7 changes: 3 additions & 4 deletions LibTest/io/Process/runSync_A01_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ String command;
List<String> args;

void setCommand() {
if (Platform.isLinux) {
command = 'echo';
args = ['abc'];
}
if (Platform.isWindows) {
command = Platform.resolvedExecutable;
args = ['--version'];
} else {
command = 'echo';
args = ['abc'];
}
}

Expand Down
11 changes: 5 additions & 6 deletions LibTest/io/Process/runSync_A02_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@ import "dart:convert";
import "dart:io";
import "../../../Utils/expect.dart";

String command;
List<String> args;
String command = "";
List<String> args = new List<String>.empty(growable: true);

void setCommand() {
if (Platform.isLinux) {
command = 'echo';
args = ['abc'];
}
if (Platform.isWindows) {
command = Platform.resolvedExecutable;
args = ['--version'];
} else {
command = 'echo';
args = ['abc'];
}
}

Expand Down
13 changes: 6 additions & 7 deletions LibTest/io/Process/runSync_A02_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/// @assertion
/// ProcessResult runSync(
/// String executable,
/// String exec utable,
/// List<String> arguments, {
/// String workingDirectory,
/// Map<String, String> environment,
Expand All @@ -30,17 +30,16 @@ import "dart:convert";
import "dart:io";
import "../../../Utils/expect.dart";

String command;
List<String> args;
String command = "";
List<String> args = new List<String>.empty(growable: true);

void setCommand() {
if (Platform.isLinux) {
command = 'echo';
args = ['abc'];
}
if (Platform.isWindows) {
command = Platform.resolvedExecutable;
args = ['--version'];
} else {
command = 'echo';
args = ['abc'];
}
}

Expand Down
7 changes: 3 additions & 4 deletions LibTest/io/Process/run_A01_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ String command;
List<String> args;

void setCommand() {
if (Platform.isLinux) {
command = 'echo';
args = ['abc'];
}
if (Platform.isWindows) {
command = Platform.resolvedExecutable;
args = ['--version'];
} else {
command = 'echo';
args = ['abc'];
}
}

Expand Down
23 changes: 19 additions & 4 deletions LibTest/io/Process/run_A01_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,29 @@
import "dart:io";
import "../../../Utils/expect.dart";

main() {
runMain() {
String executable = Platform.resolvedExecutable;
File file = new File.fromUri(Platform.script.resolve("start_A01_t01_lib.dart"));
String eScript = Platform.script.toString();

asyncStart();
Process.run(executable, [file.absolute.path]).then((ProcessResult results) {
print(Platform.executableArguments);
Process.run(executable, [...Platform.executableArguments, eScript, "run"])
.then((ProcessResult results) {
Expect.equals(0, results.exitCode);
Expect.equals("start_A01_t01_lib.dart run", results.stdout);
Expect.equals("Lily was here", results.stdout);
Expect.equals("", results.stderr);
asyncEnd();
});
}

runProcess() {
stdout.write("Lily was here");
}

main(List<String> args) {
if (args.length > 0)
runProcess();
else {
runMain();
}
}
7 changes: 3 additions & 4 deletions LibTest/io/Process/run_A02_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ String command;
List<String> args;

void setCommand() {
if (Platform.isLinux) {
command = 'echo';
args = ['abc'];
}
if (Platform.isWindows) {
command = Platform.resolvedExecutable;
args = ['--version'];
} else {
command = 'echo';
args = ['abc'];
}
}

Expand Down
7 changes: 3 additions & 4 deletions LibTest/io/Process/run_A02_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ String command;
List<String> args;

void setCommand() {
if (Platform.isLinux) {
command = 'echo';
args = ['abc'];
}
if (Platform.isWindows) {
command = Platform.resolvedExecutable;
args = ['--version'];
} else {
command = 'echo';
args = ['abc'];
}
}

Expand Down
30 changes: 22 additions & 8 deletions LibTest/io/Process/start_A01_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,34 @@ import "dart:convert";
import "dart:io";
import "../../../Utils/expect.dart";

main() {
runMain() {
String executable = Platform.resolvedExecutable;
File file = new File.fromUri(Platform.script.resolve("start_A01_t01_lib.dart"));
String eScript = Platform.script.toString();

asyncStart();
Process.start(executable, [file.path]).then((Process process) {
process.stdout.toList().then((List outList) {
Utf8Decoder decoder = new Utf8Decoder();
String decoded = decoder.convert(outList[0]);
Expect.equals("start_A01_t01_lib.dart run", decoded);
Process.start(executable, [...Platform.executableArguments, eScript, "run"])
.then((Process process) {
process.stdout.transform(utf8.decoder).transform(const LineSplitter()).
toList().then((List outList) {
Expect.equals("Lily was here", outList[0]);
}).then((_) {
process.stderr.toList().then((List errList) {
process.stderr.transform(utf8.decoder).transform(const LineSplitter()).
toList().then((List errList) {
Expect.equals(0, errList.length);
asyncEnd();
});
});
});
}

runProcess() {
stdout.write("Lily was here");
}

main(List<String> args) {
if (args.length > 0)
runProcess();
else {
runMain();
}
}
26 changes: 0 additions & 26 deletions LibTest/io/Process/start_A01_t01_lib.dart

This file was deleted.

Loading

0 comments on commit a52287c

Please sign in to comment.