22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5- import 'dart:io' ;
6-
75import 'package:test/test.dart' ;
86
97import '../utils.dart' ;
@@ -66,7 +64,7 @@ void _linkTests({required bool isNative}) {
6664 await startWatcher (path: 'links' );
6765 writeFile ('targets/a.target' , contents: 'modified' );
6866
69- // TODO(davidmorgan): reconcile differences .
67+ // Native watchers treat links as files, polling watcher polls through them .
7068 if (isNative) {
7169 await expectNoEvents ();
7270 } else {
@@ -83,7 +81,7 @@ void _linkTests({required bool isNative}) {
8381
8482 deleteFile ('targets/a.target' );
8583
86- // TODO(davidmorgan): reconcile differences .
84+ // Native watchers treat links as files, polling watcher polls through them .
8785 if (isNative) {
8886 await expectNoEvents ();
8987 } else {
@@ -115,7 +113,7 @@ void _linkTests({required bool isNative}) {
115113 target: 'targets/a.targetdir' ,
116114 unawaitedAsync: true );
117115
118- // TODO(davidmorgan): reconcile differences .
116+ // Native watchers treat links as files, polling watcher polls through them .
119117 if (isNative) {
120118 await expectAddEvent ('links/a.link' );
121119 } else {
@@ -137,7 +135,7 @@ void _linkTests({required bool isNative}) {
137135 target: 'targets/a.targetdir' ,
138136 unawaitedAsync: true );
139137
140- // TODO(davidmorgan): reconcile differences .
138+ // Native watchers treat links as files, polling watcher polls through them .
141139 if (isNative) {
142140 await expectAddEvent ('links/a.link' );
143141 } else {
@@ -154,10 +152,28 @@ void _linkTests({required bool isNative}) {
154152
155153 writeFile ('targets/a.targetdir/a.txt' );
156154
157- if (! isNative) {
155+ // Native watchers treat links as files, polling watcher polls through them.
156+ if (isNative) {
157+ await expectNoEvents ();
158+ } else {
158159 await expectAddEvent ('links/a.link/a.txt' );
160+ }
161+ });
162+
163+ test ('notifies when a file is added to a newly linked directory' , () async {
164+ createDir ('targets' );
165+ createDir ('links' );
166+ createDir ('targets/a.targetdir' );
167+ await startWatcher (path: 'links' );
168+
169+ writeLink (link: 'links/a.link' , target: 'targets/a.targetdir' );
170+ writeFile ('targets/a.targetdir/a.txt' );
171+
172+ // Native watchers treat links as files, polling watcher polls through them.
173+ if (isNative) {
174+ await expectAddEvent ('links/a.link' );
159175 } else {
160- await expectNoEvents ( );
176+ await expectAddEvent ( 'links/a.link/a.txt' );
161177 }
162178 });
163179
@@ -174,8 +190,8 @@ void _linkTests({required bool isNative}) {
174190
175191 renameDir ('links' , 'watched/links' );
176192
177- // TODO(davidmorgan): reconcile differences .
178- if (isNative && Platform .isLinux ) {
193+ // Native watchers treat links as files, polling watcher polls through them .
194+ if (isNative) {
179195 await expectAddEvent ('watched/links/a.link' );
180196 } else {
181197 await expectAddEvent ('watched/links/a.link/a.txt' );
@@ -197,8 +213,8 @@ void _linkTests({required bool isNative}) {
197213
198214 renameDir ('links' , 'watched/links' );
199215
200- // TODO(davidmorgan): reconcile differences .
201- if (isNative && Platform .isLinux ) {
216+ // Native watchers treat links as files, polling watcher polls through them .
217+ if (isNative) {
202218 await expectAddEvent ('watched/links/a.link' );
203219 } else {
204220 await expectAddEvent ('watched/links/a.link/a.txt' );
@@ -223,8 +239,8 @@ void _linkTests({required bool isNative}) {
223239
224240 renameDir ('links' , 'watched/links' );
225241
226- // TODO(davidmorgan): reconcile diffences .
227- if (isNative && Platform .isLinux ) {
242+ // Native watchers treat links as files, polling watcher polls through them .
243+ if (isNative) {
228244 await expectAddEvent ('watched/links/a.link' );
229245 } else {
230246 await expectAddEvent ('watched/links/a.link/a.txt' );
0 commit comments