Skip to content
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

Faulty LibTest/io/File/openRead_A02_t01.dart test #206

Closed
mkustermann opened this Issue Dec 14, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@mkustermann
Copy link
Member

mkustermann commented Dec 14, 2018

From LibTest/io/File/openRead_A02_t01.dart:

_main(Directory sandbox) async {
  File file = getTempFileSync(parent: sandbox);
  file.writeAsBytesSync([1, 2, 3]);
  asyncStart();
  await file.openRead().listen((data) {
    Expect.throws(() {file.deleteSync();});
  }).onDone(() {
    asyncEnd();
  });
}

Please notice that openRead().listen(...) returns a StreamSubscription object. The entire openRead().listen(...).onDone() expression returns void according to the documention.

There is therefore no point in await ...ing this expression.

Instead one could use a Completer:

_main(Directory sandbox) async {
  File file = getTempFileSync(parent: sandbox);
  file.writeAsBytesSync([1, 2, 3]);
  asyncStart();
  final c = new Completer();
  file.openRead().listen((data) {
    Expect.throws(() {file.deleteSync();});
  }).onDone(() {
    c.complete();
    asyncEnd();
  });
  return c.future;
}

Though 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).

@dcharkes

dart-bot pushed a commit to dart-lang/sdk that referenced this issue Dec 14, 2018

Skip faulty test co19/LibTest/io/File/openRead_A02_t01
Issue dart-lang/co19#206

Change-Id: I505f9b2aa6ce34078cc4f81f5791fae2b6265e05
Reviewed-on: https://dart-review.googlesource.com/c/87324
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Martin Kustermann <kustermann@google.com>

@sgrekhov sgrekhov self-assigned this Dec 17, 2018

@sgrekhov

This comment has been minimized.

Copy link
Collaborator

sgrekhov commented Dec 17, 2018

@mkustermann test was wrong, thank you for pointing. The test was rewritten. Please review #207

@sgrekhov

This comment has been minimized.

Copy link
Collaborator

sgrekhov commented Dec 17, 2018

Fixed by #207

@sgrekhov sgrekhov closed this Dec 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.