Commit Graph

47 Commits

Author SHA1 Message Date
regis@google.com b86a40f48f Fix type checking of void type.
Fix library and tests accordingly.
Add new test.
Disable new test for dart2js.
Disable some now failing co19 tests (new issue 158 filed).
Hide internal VM String types from user (not complete).
Review URL: https://chromiumcodereview.appspot.com//10787021

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9681 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-16 21:34:07 +00:00
regis@google.com dc96874999 Revert fix for type checking of void type, because some top level tests fail.
Review URL: https://chromiumcodereview.appspot.com//10784020

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9673 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-16 19:05:38 +00:00
regis@google.com a8ceb243f6 Fix type checking of void type.
Fix library and tests accordingly.
Add new test.
Disable new test for dart2js.
Disable some now failing co19 tests (new issue 158 filed).
Hide internal VM String types from user (not complete).
Review URL: https://chromiumcodereview.appspot.com//10704216

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9672 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-16 18:05:55 +00:00
ager@google.com 485bf8d10b Deal with special cmd.exe environment variables that have keys that start with an equals sign.
I have attempted to deal with them correctly instead of ignoring
them so that they can be passed on unchanged to subprocesses.

R=johnniwinther@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//10689065

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9284 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-02 10:58:24 +00:00
ajohnsen@google.com c54800f942 Give Process.kill an optional argument to specify which signal to send.
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//10545134

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8541 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-12 12:00:50 +00:00
ajohnsen@google.com 83bcc58918 Close stdin in Process.run.
This fixes an open pipe issue.

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//10532024

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8321 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-06 10:46:30 +00:00
ager@google.com 5fb75d3952 Change dart:io to use Future for one-shot operations.
This appears to be what a lot of our users are doing and it is the
style used in our other libraries.

Noteworthy changes:

- File and Directory objects are now immutable.

- Directory.list returns an active lister object.

- Write operations on files return futures and the
  onNoPendingWrites handler is gone. The same
  functionality is there by using 'then' on the
  future returned from the last write operation.

- Process starting is now done with static methods:
  -- Process.start yields an InteractiveProcess.
  -- Process.run yields a Future<ProcessResult>

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//10392023

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7529 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-11 06:09:42 +00:00
ager@google.com e6b2635059 Change Platform members to getters instead of methods.
R=sgjesse@google.com
BUG=dartbug.com/1668
TEST=

Review URL: https://chromiumcodereview.appspot.com//10351011

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7282 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-03 13:16:33 +00:00
ager@google.com 642f2b1c8e Fix exception throwing in connection with process starting.
For the run constructor, verify the arguments before starting the
underlying process.

R=sgjesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//10202014

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6995 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-26 08:56:27 +00:00
sgjesse@google.com 33565cd64a Change the error handling in dart:io
1. Change the argument on all onError handlers from Exception to
Dynamic

2. Throw an exception if an error ocours and there is no error handler
present for handling it.

For sockets there is the complication that an error on a socket is
reported to the socket error handler, and each of the stream error
handlers. The solution to this is to throw an exception if there was
no error handler on either the socket or one of the streams.

Fixed a number of bugs in tests revealed by errors no longer being
silently ignored.

R=ager@google.com

BUG=none
TEST=tests/standalone/src/io/*

Review URL: https://chromiumcodereview.appspot.com//10173024

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6994 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-26 08:12:17 +00:00
ager@google.com 493a76dd40 Support passing an environment variable map to child processes.
Fix minor type warning in test.

Reapplication after MacOS bug fix.

R=sgjesse@google.com
BUG=dartbug.com/2193
TEST=

Review URL: https://chromiumcodereview.appspot.com//10166029

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6827 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-23 07:54:10 +00:00
ager@google.com c5d347fcbc Revert "Support passing an environment variable map to child processes."
Apparently the code or the test is broken on Mac.

R=sgjesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//10163004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6795 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-20 12:53:19 +00:00
ager@google.com ee81b6f0a1 Support passing an environment variable map to child processes.
Fix minor type warning in test.

R=sgjesse@google.com
BUG=dartbug.com/2193
TEST=

Review URL: https://chromiumcodereview.appspot.com//10127008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6794 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-20 12:38:57 +00:00
ager@google.com 37b82247ac Remove need to instantiate Platform and make methods static.
This will require an update of the stable test binary. I will upload
a new build when done with the review process.

R=sgjesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//10021048

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6682 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-18 11:39:16 +00:00
ager@google.com 4e1f754730 Fix Process test, fix Process factory, diable tests on dart2js.
Florian and I will investigate the dart2js failures.

R=sgjesse@google.com,floitsch@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//10069053

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6502 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-13 09:21:54 +00:00
ager@google.com 84b0410d5a This is a request for comments.
First attempt at implementing a higher-level API for processes.
Add a startNonInteractive constructor that takes a callback which
is called with the exit code and the complete stdout and stderr
when the process terminates.

Let me know what you think. This obviously needs at least tests.
Not entirely sure what I think about the interface in the first
place.

R=sgjesse@google.com
BUG=1689
TEST=

Review URL: https://chromiumcodereview.appspot.com//9863015

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6499 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-13 08:53:35 +00:00
ager@google.com 357588d0c9 Change quoting in Process implementation on Windows.
Only quote command and arguments if they contain a space or a tab.
This seems consistent with the way it is handled in other systems.

R=antonm@google.com,sgjesse@google.com

Review URL: https://chromiumcodereview.appspot.com//9701061

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5522 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-15 15:33:06 +00:00
whesse@google.com d51bb2b427 Fix some minor static type issues in dart:io implementation.
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9703023

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5514 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-15 09:34:51 +00:00
ager@google.com b2b123d24b Update Timer API to take the callback as the last parameter.
This makes the code easier to read when the callback actually does
work:

  new Timer(1000, (t) {
    // do
    // lots
    // of
    // stuff
  });

Also, it is more consistent with the rest of the APIs.

R=sgjesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9597015

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4945 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-05 12:43:41 +00:00
ager@google.com 242bba108b Reapply dart:io API changes.
R=sgjesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9568004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4790 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-01 10:07:35 +00:00
ager@google.com fd31551ca4 Revert "Rename blahHandler to onBlah throughout dart:io."
D'oh! I need to update the test binaries as well. Reverting, building
and putting back in again.

R=sgjesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9570004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4785 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-01 09:43:15 +00:00
ager@google.com 40e0bceab5 Rename blahHandler to onBlah throughout dart:io.
Additionally, change all single-shot methods to take their callback as an argument instead of registering it on the object.

I have attempted to find all uses in the repo but there might
be some firefighting to do when this lands.

R=sgjesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9500002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4784 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-01 09:36:04 +00:00
sgjesse@google.com b4d571dcdd Handle stdio redirection in standalone VM
The recent change to epoll on Linux and kqueue on Mac OS for getting
notifications from file descriptors caused the redirection of stdin,
stdout and stderr for the stand alone VM to stop working.

On Linux epoll failed when file descriptor 0, 1 or 2 redirected from
or to a file war registered. On Mac OS there was just no events
generated from kqueue.

The streams created for stdio, stdout and stderr is now of the correct
type and for file redirections no longer a socket object holding a
file descriptor for a regular file.

Added testing of stdio redirection using both pipes and files. These
tests are currently skipped on Windows.

Fixed handlin of short socket read when reading the process exit code.

Always close the socket port when not waiting for any events.

R=iposva@google.com

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9360040

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4226 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-14 15:20:27 +00:00
ager@google.com 37499dce81 Rework Windows process handling.
- Use only one thread to wait for multiple process objects.
- Fix issue where reading from a closed pipe would print an
  error message on stderr.
- Remove the need to go to dart before removing a processinfo
  object from the list. Sometimes you never get there so we
  have to remove the process info object always.

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9310053

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3844 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-02 13:47:42 +00:00
ager@google.com 7031be2291 Revert "Changes to the process implementation."
There is a race-condition on Windows and exit handling when a process
has been closed is incorrect.

R=sgjesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9307033

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3790 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-01 14:19:25 +00:00
ager@google.com 6b5815328c Changes to the process implementation.
- Make the list of active processes thread safe on Windows.
- Use only one thread on Windows to detect process termination.
- Stop the process termination thread when the standalone VM terminates.

R=sgjesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9307003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3780 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-01 09:09:23 +00:00
ager@google.com c46939aa66 Comment and white-space cleanup in IO libraries.
- use dart doc comment for interface comments.
- use '//' style comments for non-doc comments.
- remove some whitespace.

R=whesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9285017

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3554 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-24 15:39:58 +00:00
whesse@google.com 480722154a Fix assertion failure in Process object, where non-integer pid could be passed to kill.
BUG=
TEST=

Review URL: http://codereview.chromium.org//9120004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3038 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-06 13:54:31 +00:00
ajohnsen@google.com c2b45bf04e Add optional workingDirectory argument to Process.start.
Review URL: http://codereview.chromium.org//9108008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@2987 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-05 09:54:54 +00:00
sgjesse@google.com 8055ffeb77 Add close to input stream and cleanup socket and streams
* All input streams now have a close method for just cutting
  the stream
* Removed interfaces FileInputStream and FileOutputStream
* Added exceptions to socket to avoid mixing stream and non-stream
  use of the same socket
* Added special handling of the socket connect handler callback

R=ager@google.com

BUG=
TEST=

Review URL: http://codereview.chromium.org//9029001

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@2893 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-02 13:00:59 +00:00
ager@google.com 27508f3eb1 Change the process API to be completely asynchronous.
Some of the implementation is still not asynchronous but the API is
now prepared for it.

This is a breaking change for the dart test scripts. Once the
change has its final form I will add new stable builds of the
VM to the changelist for running tests.

R=sgjesse@google.com
BUG=
TEST=

Review URL: http://codereview.chromium.org//9024008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@2753 260f80e4-7a28-3924-810f-c04153c831b5
2011-12-22 13:43:43 +00:00
sgjesse@google.com d7c8c1f1e4 Fix a number of issues with the process handling
1. Ignore the signal SIGPIPE on Linux and Mac OS

When reading from or writing to a closed pipe the signal SIGPIPE
is raised. The default handling of this is to terminate the
program. When signal SIGPIPE is ignored the read and write
returns EPIPE.

2. Wrong return type for stdio getter

3. When there is an error on a socket mark it as closed

4. Mark the pipe used for process exit status as a one way pipe

5. Add tests to test stdin, stdout and stderr in Dart scripts

R=ager@google.com

BUG=dart:536, dart:454
TEST=

Review URL: http://codereview.chromium.org//8662006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1793 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-23 14:49:18 +00:00
sgjesse@google.com 38b2b0d5d8 Provide access to stdin, stdout and stderr
R=ager@google.com, iposva@google.com

BUG=dart:402
TEST=

Review URL: http://codereview.chromium.org//8525002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1456 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-11 11:45:53 +00:00
ager@google.com f789c40d85 Correct the sign of exit codes for the process library.
BUG=
TEST=

Review URL: http://codereview.chromium.org//8506013

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1356 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-09 15:37:40 +00:00
sgjesse@google.com 516d71ab0b Change the handling of closing sockets
Sockets now supports being half-closed for either reading or writing. When a socket is closed it is by default closed for both read and write and the underlying file descriptor is destroyed. However the socket close can be asked to only half-close the socket to send end of stream to the other end and still have the ability to receive more data.

The close event on a socket is only emitted when the socket is closed by the other end. Both half-close and full-close by the other end is reported as a close event. If a socket is already half closed the close event will automatically destroy the socket.

The streams on the sockets also takes advantage of this. A socket input stream will report a close event when the other end closed. A socket output stream will half-close the socket when close is called making it possible to still receive data on the input stream. When both streams have been closed the socket is destroyed.

For sockets operating on pipes they are initially created as half-closed for either reading or writing depending on which type of pipe a socket object is based on. A pipe for writing will start half-closed for reading so if it is only half-closed for writing the socket will still be destroyed. Same with a pipe for reading that will start half-closed for writing and when a close event is received half-closing the other direction will destroy the socket. Socket objects based on pipes are only exposed through streams.

Extended the socket close test to test a number of different scenarios.

Also refactor the socket data C++ object to encapsulate more socket information and operations.

Now the Linux and Mac OS versions are 100% the same as it turned out that using POLLRDHUP on Linux was not required any more.

R=ager@google.com

BUG=
TEST=

Review URL: http://codereview.chromium.org//8437090

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1196 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-04 12:34:43 +00:00
ager@google.com ba34b6eb98 Fix process test and implementation after change to setter for registering event handler.
R=sgjesse@google.com
BUG=
TEST=

Review URL: http://codereview.chromium.org//8440035

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1084 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-02 12:50:59 +00:00
ager@google.com 362d04f9af Consistently use setters to set event handlers in native APIs.
R=sgjesse@google.com
BUG=
TEST=

Review URL: http://codereview.chromium.org//8386029

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1083 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-02 12:12:43 +00:00
sgjesse@google.com 18e5ef8da5 New OutputStream interface
R=ager@google.com

BUG=
TEST=

Review URL: http://codereview.chromium.org//8413034

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@997 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-01 10:10:37 +00:00
srdjan@google.com 8d69118676 More strict non-equal cleanups in library code
Review URL: http://codereview.chromium.org//8413018

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@892 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-28 15:21:42 +00:00
srdjan@google.com 959f4b519d Use strict equality when comparing with null, especially when null is a default value.
Review URL: http://codereview.chromium.org//8400038

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@859 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-27 22:11:16 +00:00
sgjesse@google.com 00a00bcdb4 This contains a new InputStream and StringInputStream interfaces.
The readUntil is only supported through readLine on the StringInputStream.

The StringInputStream implementation in string_stream.dart could live outside the VM as it is plain Dart code.

BUG=
TEST=

Review URL: http://codereview.chromium.org//8318009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@747 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-26 13:17:28 +00:00
ager@google.com 86284155b9 Improve error handling in the process library.
Verify that the arguments have the types expected by the
implementation. Require a List instance containing builtin
Strings as the arguments. Require a builtin String path.

R=sgjesse@google.com
BUG=
TEST=

Review URL: http://codereview.chromium.org//8383037

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@690 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-25 12:16:04 +00:00
sgjesse@google.com ebe5b49e51 Added file missing from last commit
TBR=rchandia@google.com

Review URL: http://codereview.chromium.org//8364041

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@604 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-21 15:36:15 +00:00
sgjesse@google.com 786aee238a Fix the handling of exceptions from process start
The privious change in r389 where the sockets used to communicate with the chile process did not work. Even though the Socket objects are not assigned any file descriptor they should still have their Dart port closed. If not the VM will not terminate.

TBR=ager@google.com

TEST=ProcessStartExceptionTest.dart
BUG=none

Review URL: http://codereview.chromium.org//8270001

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@395 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-13 13:31:51 +00:00
sgjesse@google.com d0496ec807 Implement the full process interface for Windows
There are still a couple of TODOs in the code.

R=ager@google.com
Review URL: http://codereview.chromium.org//8249007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@389 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-13 10:38:37 +00:00
sgjesse@google.com b7485553a2 Fix deadlock in process exit handling
As glibc allocation routines are not re-entrant avoid calling delete in signal handler.

Instead the message send from the signal handler on process exit contains both the pid and the exit code. The internal _Process object always installs a data handler for the exit message and calls back into C++ to cleanup the resources allocated for running a process.

Changed the ActiveProcess (renamed to ProcessInfo) to form an explicitly linked list.

R=ager@google.com

BUG=dart:1
TEST=

Review URL: http://codereview.chromium.org//8227010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@325 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-11 11:26:12 +00:00
dgrove@google.com 4c0f559d23 Initial checkin.
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-05 05:20:07 +00:00