{"action":"closed","issue":{"url":"https://api.github.com/repos/dart-lang/co19/issues/206","repository_url":"https://api.github.com/repos/dart-lang/co19","labels_url":"https://api.github.com/repos/dart-lang/co19/issues/206/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/co19/issues/206/comments","events_url":"https://api.github.com/repos/dart-lang/co19/issues/206/events","html_url":"https://github.com/dart-lang/co19/issues/206","id":391166316,"node_id":"MDU6SXNzdWUzOTExNjYzMTY=","number":206,"title":"Faulty LibTest/io/File/openRead_A02_t01.dart test","user":{"login":"mkustermann","id":5757092,"node_id":"MDQ6VXNlcjU3NTcwOTI=","avatar_url":"https://avatars2.githubusercontent.com/u/5757092?v=4","gravatar_id":"","url":"https://api.github.com/users/mkustermann","html_url":"https://github.com/mkustermann","followers_url":"https://api.github.com/users/mkustermann/followers","following_url":"https://api.github.com/users/mkustermann/following{/other_user}","gists_url":"https://api.github.com/users/mkustermann/gists{/gist_id}","starred_url":"https://api.github.com/users/mkustermann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkustermann/subscriptions","organizations_url":"https://api.github.com/users/mkustermann/orgs","repos_url":"https://api.github.com/users/mkustermann/repos","events_url":"https://api.github.com/users/mkustermann/events{/privacy}","received_events_url":"https://api.github.com/users/mkustermann/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"sgrekhov","id":4627088,"node_id":"MDQ6VXNlcjQ2MjcwODg=","avatar_url":"https://avatars1.githubusercontent.com/u/4627088?v=4","gravatar_id":"","url":"https://api.github.com/users/sgrekhov","html_url":"https://github.com/sgrekhov","followers_url":"https://api.github.com/users/sgrekhov/followers","following_url":"https://api.github.com/users/sgrekhov/following{/other_user}","gists_url":"https://api.github.com/users/sgrekhov/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrekhov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrekhov/subscriptions","organizations_url":"https://api.github.com/users/sgrekhov/orgs","repos_url":"https://api.github.com/users/sgrekhov/repos","events_url":"https://api.github.com/users/sgrekhov/events{/privacy}","received_events_url":"https://api.github.com/users/sgrekhov/received_events","type":"User","site_admin":false},"assignees":[{"login":"sgrekhov","id":4627088,"node_id":"MDQ6VXNlcjQ2MjcwODg=","avatar_url":"https://avatars1.githubusercontent.com/u/4627088?v=4","gravatar_id":"","url":"https://api.github.com/users/sgrekhov","html_url":"https://github.com/sgrekhov","followers_url":"https://api.github.com/users/sgrekhov/followers","following_url":"https://api.github.com/users/sgrekhov/following{/other_user}","gists_url":"https://api.github.com/users/sgrekhov/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrekhov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrekhov/subscriptions","organizations_url":"https://api.github.com/users/sgrekhov/orgs","repos_url":"https://api.github.com/users/sgrekhov/repos","events_url":"https://api.github.com/users/sgrekhov/events{/privacy}","received_events_url":"https://api.github.com/users/sgrekhov/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2018-12-14T15:55:58Z","updated_at":"2018-12-17T11:23:57Z","closed_at":"2018-12-17T11:23:57Z","author_association":"MEMBER","body":"From [LibTest/io/File/openRead_A02_t01.dart](https://github.com/dart-lang/co19/blob/master/LibTest/io/File/openRead_A02_t01.dart):\r\n```dart\r\n_main(Directory sandbox) async {\r\n  File file = getTempFileSync(parent: sandbox);\r\n  file.writeAsBytesSync([1, 2, 3]);\r\n  asyncStart();\r\n  await file.openRead().listen((data) {\r\n    Expect.throws(() {file.deleteSync();});\r\n  }).onDone(() {\r\n    asyncEnd();\r\n  });\r\n}\r\n```\r\n\r\nPlease notice that `openRead().listen(...)` returns a `StreamSubscription` object. The entire `openRead().listen(...).onDone()` expression returns `void` according to the [documention](https://api.dartlang.org/stable/2.1.0/dart-async/StreamSubscription/onDone.html).\r\n\r\nThere is therefore no point in `await ...`ing this expression.\r\n\r\nInstead one could use a Completer:\r\n```dart\r\n_main(Directory sandbox) async {\r\n  File file = getTempFileSync(parent: sandbox);\r\n  file.writeAsBytesSync([1, 2, 3]);\r\n  asyncStart();\r\n  final c = new Completer();\r\n  file.openRead().listen((data) {\r\n    Expect.throws(() {file.deleteSync();});\r\n  }).onDone(() {\r\n    c.complete();\r\n    asyncEnd();\r\n  });\r\n  return c.future;\r\n}\r\n```\r\n\r\nThough now the question comes up what this test is actually testing. The  `Expect.throws(() {file.deleteSync();});`  statement expects that the file cannot be deleted while we are getting data. This is not the case on most platforms. For one, the data we get might be the last, so we might have already gotten the EOF (end-of-file).  Furthermore on platforms like linux one can easily open a file, someone deletes the file, and we can continue reading from it (this works until the last file open file descriptor is droped, then the file is actually deleted).\r\n\r\n@dcharkes "}}
{"actor":{"display_login":"sgrekhov"}}