From 69ebb2ad1b602117d45d0f35429821554996ad41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Nicouleaud?= Date: Thu, 4 Apr 2019 15:46:25 +0200 Subject: [PATCH 1/6] core/local/atom_watcher: Don't check platform in .producer() --- core/local/atom/watcher.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/core/local/atom/watcher.js b/core/local/atom/watcher.js index 4d4d983c1..ded753018 100644 --- a/core/local/atom/watcher.js +++ b/core/local/atom/watcher.js @@ -82,11 +82,7 @@ const steps = _.compact([ /** The producer for the current platform. */ const producer = opts => { - if (['linux', 'win32'].includes(process.platform)) { - return new Producer(opts) - } else { - throw new Error('The atom watcher is not available on this platform') - } + return new Producer(opts) } const stepsInitialState = ( From c7ef0af7bc3cdf01c0dc07135d38762f2142deed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Nicouleaud?= Date: Fri, 5 Apr 2019 17:44:15 +0200 Subject: [PATCH 2/6] test/support/helpers/scenarios: Don't run Windows scenarios on macOS --- test/support/helpers/scenarios.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/support/helpers/scenarios.js b/test/support/helpers/scenarios.js index b01635bb6..01b2cf2c6 100644 --- a/test/support/helpers/scenarios.js +++ b/test/support/helpers/scenarios.js @@ -129,7 +129,10 @@ module.exports.loadAtomCaptures = scenario => { const disabledEventsFile = name => { if (process.platform === 'win32' && name.indexOf('win32') === -1) { return 'linux test' - } else if (process.platform === 'linux' && name.indexOf('win32') >= 0) { + } else if ( + ['linux', 'darwin'].includes(process.platform) && + name.indexOf('win32') >= 0 + ) { return 'win32 test' } else { return disabledScenarioTest(scenario, `atom/${name}`) From 09292bc08146e4b6a8dfcf7713b2287a8ad6a868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Nicouleaud?= Date: Fri, 5 Apr 2019 17:36:25 +0200 Subject: [PATCH 3/6] test/scenarios: Generate atom/darwin captures --- .../add_delete_dir_and_file/atom/darwin.json | 27 ++ test/scenarios/add_file/atom/darwin.json | 9 + test/scenarios/add_trash_dir/atom/darwin.json | 17 + .../scenarios/add_trash_file/atom/darwin.json | 16 + test/scenarios/change_file/atom/darwin.json | 9 + .../atom/darwin.json | 16 + test/scenarios/create_dirs/atom/darwin.json | 43 ++ .../atom/darwin.json | 18 + .../move_and_trash_dir/atom/darwin.json | 24 ++ .../move_and_trash_file/atom/darwin.json | 17 + .../move_and_update_file/atom/darwin.json | 17 + .../atom/darwin.json | 26 ++ .../atom/darwin.json | 17 + .../atom/darwin.json | 89 +++++ .../atom/darwin.json | 43 ++ .../move_dir_reversed_events/atom/darwin.json | 10 + .../atom/darwin.json | 15 + .../atom/darwin.json | 18 + .../move_dir_with_content/atom/darwin.json | 10 + test/scenarios/move_file/atom/darwin.json | 10 + .../atom/darwin.json | 26 ++ .../move_file_inside_move/atom/darwin.json | 22 ++ .../atom/darwin.json | 10 + .../move_file_successive/atom/darwin.json | 18 + .../move_file_successive_2/atom/darwin.json | 18 + .../atom/darwin.json | 18 + .../move_from_inside_move/atom/darwin.json | 16 + .../move_merging_dir/atom/darwin.json | 54 +++ .../move_overwriting_dir/atom/darwin.json | 373 ++++++++++++++++++ .../move_overwriting_file/atom/darwin.json | 17 + test/scenarios/move_two_dirs/atom/darwin.json | 18 + .../atom/darwin.json | 17 + .../scenarios/move_two_files/atom/darwin.json | 18 + .../rename_identical/atom/darwin.json | 38 ++ .../atom/darwin.json | 1 + .../atom/darwin.json | 26 ++ .../trash_dir_with_content/atom/darwin.json | 24 ++ 37 files changed, 1165 insertions(+) create mode 100644 test/scenarios/add_delete_dir_and_file/atom/darwin.json create mode 100644 test/scenarios/add_file/atom/darwin.json create mode 100644 test/scenarios/add_trash_dir/atom/darwin.json create mode 100644 test/scenarios/add_trash_file/atom/darwin.json create mode 100644 test/scenarios/change_file/atom/darwin.json create mode 100644 test/scenarios/create_dir_into_moved_one/atom/darwin.json create mode 100644 test/scenarios/create_dirs/atom/darwin.json create mode 100644 test/scenarios/move_a_to_c_and_b_to_a_dir_dir_delay/atom/darwin.json create mode 100644 test/scenarios/move_and_trash_dir/atom/darwin.json create mode 100644 test/scenarios/move_and_trash_file/atom/darwin.json create mode 100644 test/scenarios/move_and_update_file/atom/darwin.json create mode 100644 test/scenarios/move_dir_a_to_b_to_c_to_b/atom/darwin.json create mode 100644 test/scenarios/move_dir_and_update_subfile/atom/darwin.json create mode 100644 test/scenarios/move_dir_from_the_outside/atom/darwin.json create mode 100644 test/scenarios/move_dir_into_created_one/atom/darwin.json create mode 100644 test/scenarios/move_dir_reversed_events/atom/darwin.json create mode 100644 test/scenarios/move_dir_successive_same_level/atom/darwin.json create mode 100644 test/scenarios/move_dir_successive_with_delay/atom/darwin.json create mode 100644 test/scenarios/move_dir_with_content/atom/darwin.json create mode 100644 test/scenarios/move_file/atom/darwin.json create mode 100644 test/scenarios/move_file_a_to_b_to_c_to_b/atom/darwin.json create mode 100644 test/scenarios/move_file_inside_move/atom/darwin.json create mode 100644 test/scenarios/move_file_reversed_events/atom/darwin.json create mode 100644 test/scenarios/move_file_successive/atom/darwin.json create mode 100644 test/scenarios/move_file_successive_2/atom/darwin.json create mode 100644 test/scenarios/move_files_a_to_c_and_b_to_a/atom/darwin.json create mode 100644 test/scenarios/move_from_inside_move/atom/darwin.json create mode 100644 test/scenarios/move_merging_dir/atom/darwin.json create mode 100644 test/scenarios/move_overwriting_dir/atom/darwin.json create mode 100644 test/scenarios/move_overwriting_file/atom/darwin.json create mode 100644 test/scenarios/move_two_dirs/atom/darwin.json create mode 100644 test/scenarios/move_two_dirs_same_prefix/atom/darwin.json create mode 100644 test/scenarios/move_two_files/atom/darwin.json create mode 100644 test/scenarios/rename_identical/atom/darwin.json create mode 100644 test/scenarios/rename_identical_local_loopback/atom/darwin.json create mode 100644 test/scenarios/rename_subdir_after_parent/atom/darwin.json create mode 100644 test/scenarios/trash_dir_with_content/atom/darwin.json diff --git a/test/scenarios/add_delete_dir_and_file/atom/darwin.json b/test/scenarios/add_delete_dir_and_file/atom/darwin.json new file mode 100644 index 000000000..11da9449a --- /dev/null +++ b/test/scenarios/add_delete_dir_and_file/atom/darwin.json @@ -0,0 +1,27 @@ +[ + [ + { + "action": "created", + "kind": "directory", + "path": "dir" + }, + { + "action": "created", + "kind": "file", + "path": "file" + } + ], + [], + [ + { + "action": "deleted", + "kind": "directory", + "path": "dir" + }, + { + "action": "deleted", + "kind": "file", + "path": "file" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/add_file/atom/darwin.json b/test/scenarios/add_file/atom/darwin.json new file mode 100644 index 000000000..74c129431 --- /dev/null +++ b/test/scenarios/add_file/atom/darwin.json @@ -0,0 +1,9 @@ +[ + [ + { + "action": "created", + "kind": "file", + "path": "file" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/add_trash_dir/atom/darwin.json b/test/scenarios/add_trash_dir/atom/darwin.json new file mode 100644 index 000000000..7d0fc54c5 --- /dev/null +++ b/test/scenarios/add_trash_dir/atom/darwin.json @@ -0,0 +1,17 @@ +[ + [ + { + "action": "created", + "kind": "directory", + "path": "dir" + } + ], + [], + [ + { + "action": "deleted", + "kind": "directory", + "path": "dir" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/add_trash_file/atom/darwin.json b/test/scenarios/add_trash_file/atom/darwin.json new file mode 100644 index 000000000..cb3b2976c --- /dev/null +++ b/test/scenarios/add_trash_file/atom/darwin.json @@ -0,0 +1,16 @@ +[ + [ + { + "action": "created", + "kind": "file", + "path": "file" + } + ], + [ + { + "action": "deleted", + "kind": "file", + "path": "file" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/change_file/atom/darwin.json b/test/scenarios/change_file/atom/darwin.json new file mode 100644 index 000000000..586fe590e --- /dev/null +++ b/test/scenarios/change_file/atom/darwin.json @@ -0,0 +1,9 @@ +[ + [ + { + "action": "modified", + "kind": "file", + "path": "file" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/create_dir_into_moved_one/atom/darwin.json b/test/scenarios/create_dir_into_moved_one/atom/darwin.json new file mode 100644 index 000000000..aa2474230 --- /dev/null +++ b/test/scenarios/create_dir_into_moved_one/atom/darwin.json @@ -0,0 +1,16 @@ +[ + [ + { + "action": "renamed", + "kind": "directory", + "path": "dst/dir1", + "oldPath": "src/dir1" + }, + { + "action": "created", + "kind": "directory", + "path": "dst/dir1/dir2" + } + ], + [] +] \ No newline at end of file diff --git a/test/scenarios/create_dirs/atom/darwin.json b/test/scenarios/create_dirs/atom/darwin.json new file mode 100644 index 000000000..6c6365053 --- /dev/null +++ b/test/scenarios/create_dirs/atom/darwin.json @@ -0,0 +1,43 @@ +[ + [ + { + "action": "created", + "kind": "directory", + "path": "foo" + }, + { + "action": "created", + "kind": "directory", + "path": "foo/bar" + } + ], + [], + [ + { + "action": "scan", + "path": "foo/bar", + "kind": "directory", + "stats": { + "dev": 16777226, + "mode": 16877, + "nlink": 2, + "uid": 501, + "gid": 20, + "rdev": 0, + "blksize": 4194304, + "ino": 8600863105, + "size": 64, + "blocks": 0, + "atimeMs": 1554478410553.5947, + "mtimeMs": 1554478410533.3728, + "ctimeMs": 1554478410533.3728, + "birthtimeMs": 1554478410533.3728, + "atime": "2019-04-05T15:33:30.554Z", + "mtime": "2019-04-05T15:33:30.533Z", + "ctime": "2019-04-05T15:33:30.533Z", + "birthtime": "2019-04-05T15:33:30.533Z" + } + } + ], + [] +] \ No newline at end of file diff --git a/test/scenarios/move_a_to_c_and_b_to_a_dir_dir_delay/atom/darwin.json b/test/scenarios/move_a_to_c_and_b_to_a_dir_dir_delay/atom/darwin.json new file mode 100644 index 000000000..9de422053 --- /dev/null +++ b/test/scenarios/move_a_to_c_and_b_to_a_dir_dir_delay/atom/darwin.json @@ -0,0 +1,18 @@ +[ + [ + { + "action": "renamed", + "kind": "directory", + "path": "c", + "oldPath": "a" + } + ], + [ + { + "action": "renamed", + "kind": "directory", + "path": "a", + "oldPath": "b" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_and_trash_dir/atom/darwin.json b/test/scenarios/move_and_trash_dir/atom/darwin.json new file mode 100644 index 000000000..f315bbe65 --- /dev/null +++ b/test/scenarios/move_and_trash_dir/atom/darwin.json @@ -0,0 +1,24 @@ +[ + [ + { + "action": "renamed", + "kind": "directory", + "path": "dst/subdir", + "oldPath": "src/subdir" + } + ], + [ + { + "action": "deleted", + "kind": "file", + "path": "dst/subdir/file" + } + ], + [ + { + "action": "deleted", + "kind": "directory", + "path": "dst/subdir" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_and_trash_file/atom/darwin.json b/test/scenarios/move_and_trash_file/atom/darwin.json new file mode 100644 index 000000000..7351d57b2 --- /dev/null +++ b/test/scenarios/move_and_trash_file/atom/darwin.json @@ -0,0 +1,17 @@ +[ + [ + { + "action": "renamed", + "kind": "file", + "path": "dst/file", + "oldPath": "src/file" + } + ], + [ + { + "action": "deleted", + "kind": "file", + "path": "dst/file" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_and_update_file/atom/darwin.json b/test/scenarios/move_and_update_file/atom/darwin.json new file mode 100644 index 000000000..64689a000 --- /dev/null +++ b/test/scenarios/move_and_update_file/atom/darwin.json @@ -0,0 +1,17 @@ +[ + [ + { + "action": "renamed", + "kind": "file", + "path": "dst/file", + "oldPath": "src/file" + } + ], + [ + { + "action": "modified", + "kind": "file", + "path": "dst/file" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_dir_a_to_b_to_c_to_b/atom/darwin.json b/test/scenarios/move_dir_a_to_b_to_c_to_b/atom/darwin.json new file mode 100644 index 000000000..dfc21041f --- /dev/null +++ b/test/scenarios/move_dir_a_to_b_to_c_to_b/atom/darwin.json @@ -0,0 +1,26 @@ +[ + [ + { + "action": "renamed", + "kind": "directory", + "path": "src/B", + "oldPath": "src/A" + } + ], + [ + { + "action": "renamed", + "kind": "directory", + "path": "src/C", + "oldPath": "src/B" + } + ], + [ + { + "action": "renamed", + "kind": "directory", + "path": "src/B", + "oldPath": "src/C" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_dir_and_update_subfile/atom/darwin.json b/test/scenarios/move_dir_and_update_subfile/atom/darwin.json new file mode 100644 index 000000000..acaa58ea2 --- /dev/null +++ b/test/scenarios/move_dir_and_update_subfile/atom/darwin.json @@ -0,0 +1,17 @@ +[ + [ + { + "action": "renamed", + "kind": "directory", + "path": "dst", + "oldPath": "src" + } + ], + [ + { + "action": "modified", + "kind": "file", + "path": "dst/file" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_dir_from_the_outside/atom/darwin.json b/test/scenarios/move_dir_from_the_outside/atom/darwin.json new file mode 100644 index 000000000..70ae4a34b --- /dev/null +++ b/test/scenarios/move_dir_from_the_outside/atom/darwin.json @@ -0,0 +1,89 @@ +[ + [ + { + "action": "created", + "kind": "directory", + "path": "dst/dir" + } + ], + [ + { + "action": "scan", + "path": "dst/dir/empty-subdir", + "kind": "directory", + "stats": { + "dev": 16777226, + "mode": 16877, + "nlink": 2, + "uid": 501, + "gid": 20, + "rdev": 0, + "blksize": 4194304, + "ino": 3, + "size": 64, + "blocks": 0, + "atimeMs": 1554478270675.5823, + "mtimeMs": 1554478269550.599, + "ctimeMs": 1554478269550.599, + "birthtimeMs": 1554478269550.599, + "atime": "2019-04-05T15:31:10.676Z", + "mtime": "2019-04-05T15:31:09.551Z", + "ctime": "2019-04-05T15:31:09.551Z", + "birthtime": "2019-04-05T15:31:09.551Z" + } + }, + { + "action": "scan", + "path": "dst/dir/subdir", + "kind": "directory", + "stats": { + "dev": 16777226, + "mode": 16877, + "nlink": 3, + "uid": 501, + "gid": 20, + "rdev": 0, + "blksize": 4194304, + "ino": 4, + "size": 96, + "blocks": 0, + "atimeMs": 1554478270676.1643, + "mtimeMs": 1554478269553.088, + "ctimeMs": 1554478269553.088, + "birthtimeMs": 1554478269551.147, + "atime": "2019-04-05T15:31:10.676Z", + "mtime": "2019-04-05T15:31:09.553Z", + "ctime": "2019-04-05T15:31:09.553Z", + "birthtime": "2019-04-05T15:31:09.551Z" + } + } + ], + [], + [ + { + "action": "scan", + "path": "dst/dir/subdir/file", + "kind": "file", + "stats": { + "dev": 16777226, + "mode": 33188, + "nlink": 1, + "uid": 501, + "gid": 20, + "rdev": 0, + "blksize": 4194304, + "ino": 5, + "size": 8, + "blocks": 8, + "atimeMs": 1554478270574.384, + "mtimeMs": 1554478269553.8943, + "ctimeMs": 1554478269553.8943, + "birthtimeMs": 1554478269553.069, + "atime": "2019-04-05T15:31:10.574Z", + "mtime": "2019-04-05T15:31:09.554Z", + "ctime": "2019-04-05T15:31:09.554Z", + "birthtime": "2019-04-05T15:31:09.553Z" + } + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_dir_into_created_one/atom/darwin.json b/test/scenarios/move_dir_into_created_one/atom/darwin.json new file mode 100644 index 000000000..41acb110f --- /dev/null +++ b/test/scenarios/move_dir_into_created_one/atom/darwin.json @@ -0,0 +1,43 @@ +[ + [ + { + "action": "created", + "kind": "directory", + "path": "dir2" + }, + { + "action": "renamed", + "kind": "directory", + "path": "dir2/dir1", + "oldPath": "dir1" + } + ], + [ + { + "action": "scan", + "path": "dir2/dir1", + "kind": "directory", + "stats": { + "dev": 16777226, + "mode": 16877, + "nlink": 2, + "uid": 501, + "gid": 20, + "rdev": 0, + "blksize": 4194304, + "ino": 1, + "size": 64, + "blocks": 0, + "atimeMs": 1554478416607.126, + "mtimeMs": 1554478415548.0994, + "ctimeMs": 1554478416594.3884, + "birthtimeMs": 1554478415548.0994, + "atime": "2019-04-05T15:33:36.607Z", + "mtime": "2019-04-05T15:33:35.548Z", + "ctime": "2019-04-05T15:33:36.594Z", + "birthtime": "2019-04-05T15:33:35.548Z" + } + } + ], + [] +] \ No newline at end of file diff --git a/test/scenarios/move_dir_reversed_events/atom/darwin.json b/test/scenarios/move_dir_reversed_events/atom/darwin.json new file mode 100644 index 000000000..0ee92460c --- /dev/null +++ b/test/scenarios/move_dir_reversed_events/atom/darwin.json @@ -0,0 +1,10 @@ +[ + [ + { + "action": "renamed", + "kind": "directory", + "path": "dst/dir", + "oldPath": "src/dir" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_dir_successive_same_level/atom/darwin.json b/test/scenarios/move_dir_successive_same_level/atom/darwin.json new file mode 100644 index 000000000..38ecfce0f --- /dev/null +++ b/test/scenarios/move_dir_successive_same_level/atom/darwin.json @@ -0,0 +1,15 @@ +[ + [ + { + "action": "renamed", + "kind": "directory", + "path": "parent/dst2/dir", + "oldPath": "parent/src/dir" + }, + { + "action": "deleted", + "kind": "directory", + "path": "parent/dst1/dir" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_dir_successive_with_delay/atom/darwin.json b/test/scenarios/move_dir_successive_with_delay/atom/darwin.json new file mode 100644 index 000000000..d62f6a83e --- /dev/null +++ b/test/scenarios/move_dir_successive_with_delay/atom/darwin.json @@ -0,0 +1,18 @@ +[ + [ + { + "action": "renamed", + "kind": "directory", + "path": "parent/dst1/dir", + "oldPath": "parent/src/dir" + } + ], + [ + { + "action": "renamed", + "kind": "directory", + "path": "parent/dst2/dir", + "oldPath": "parent/dst1/dir" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_dir_with_content/atom/darwin.json b/test/scenarios/move_dir_with_content/atom/darwin.json new file mode 100644 index 000000000..16bcb2a36 --- /dev/null +++ b/test/scenarios/move_dir_with_content/atom/darwin.json @@ -0,0 +1,10 @@ +[ + [ + { + "action": "renamed", + "kind": "directory", + "path": "parent/dst/dir", + "oldPath": "parent/src/dir" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_file/atom/darwin.json b/test/scenarios/move_file/atom/darwin.json new file mode 100644 index 000000000..ce1437d87 --- /dev/null +++ b/test/scenarios/move_file/atom/darwin.json @@ -0,0 +1,10 @@ +[ + [ + { + "action": "renamed", + "kind": "file", + "path": "dst/file", + "oldPath": "src/file" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_file_a_to_b_to_c_to_b/atom/darwin.json b/test/scenarios/move_file_a_to_b_to_c_to_b/atom/darwin.json new file mode 100644 index 000000000..7edd7d76c --- /dev/null +++ b/test/scenarios/move_file_a_to_b_to_c_to_b/atom/darwin.json @@ -0,0 +1,26 @@ +[ + [ + { + "action": "renamed", + "kind": "file", + "path": "src/B", + "oldPath": "src/A" + } + ], + [ + { + "action": "renamed", + "kind": "file", + "path": "src/C", + "oldPath": "src/B" + } + ], + [ + { + "action": "renamed", + "kind": "file", + "path": "src/B", + "oldPath": "src/C" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_file_inside_move/atom/darwin.json b/test/scenarios/move_file_inside_move/atom/darwin.json new file mode 100644 index 000000000..d79ac98c6 --- /dev/null +++ b/test/scenarios/move_file_inside_move/atom/darwin.json @@ -0,0 +1,22 @@ +[ + [ + { + "action": "renamed", + "kind": "directory", + "path": "parent/dst/dir", + "oldPath": "parent/src/dir" + }, + { + "action": "renamed", + "kind": "file", + "path": "parent/dst/dir/subdir/filerenamed2", + "oldPath": "parent/dst/dir/subdir/file2" + }, + { + "action": "renamed", + "kind": "file", + "path": "parent/src/dir/subdir/filerenamed", + "oldPath": "parent/src/dir/subdir/file" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_file_reversed_events/atom/darwin.json b/test/scenarios/move_file_reversed_events/atom/darwin.json new file mode 100644 index 000000000..ce1437d87 --- /dev/null +++ b/test/scenarios/move_file_reversed_events/atom/darwin.json @@ -0,0 +1,10 @@ +[ + [ + { + "action": "renamed", + "kind": "file", + "path": "dst/file", + "oldPath": "src/file" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_file_successive/atom/darwin.json b/test/scenarios/move_file_successive/atom/darwin.json new file mode 100644 index 000000000..d535d71eb --- /dev/null +++ b/test/scenarios/move_file_successive/atom/darwin.json @@ -0,0 +1,18 @@ +[ + [ + { + "action": "renamed", + "kind": "file", + "path": "dst1/file", + "oldPath": "src/file" + } + ], + [ + { + "action": "renamed", + "kind": "file", + "path": "dst2/file", + "oldPath": "dst1/file" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_file_successive_2/atom/darwin.json b/test/scenarios/move_file_successive_2/atom/darwin.json new file mode 100644 index 000000000..d535d71eb --- /dev/null +++ b/test/scenarios/move_file_successive_2/atom/darwin.json @@ -0,0 +1,18 @@ +[ + [ + { + "action": "renamed", + "kind": "file", + "path": "dst1/file", + "oldPath": "src/file" + } + ], + [ + { + "action": "renamed", + "kind": "file", + "path": "dst2/file", + "oldPath": "dst1/file" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_files_a_to_c_and_b_to_a/atom/darwin.json b/test/scenarios/move_files_a_to_c_and_b_to_a/atom/darwin.json new file mode 100644 index 000000000..9dc3cf7f9 --- /dev/null +++ b/test/scenarios/move_files_a_to_c_and_b_to_a/atom/darwin.json @@ -0,0 +1,18 @@ +[ + [ + { + "action": "renamed", + "kind": "file", + "path": "c", + "oldPath": "a" + } + ], + [ + { + "action": "renamed", + "kind": "file", + "path": "a", + "oldPath": "b" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_from_inside_move/atom/darwin.json b/test/scenarios/move_from_inside_move/atom/darwin.json new file mode 100644 index 000000000..e77500429 --- /dev/null +++ b/test/scenarios/move_from_inside_move/atom/darwin.json @@ -0,0 +1,16 @@ +[ + [ + { + "action": "renamed", + "kind": "directory", + "path": "parent/dst/dir", + "oldPath": "parent/src/dir" + }, + { + "action": "renamed", + "kind": "directory", + "path": "parent/dst2/subdir", + "oldPath": "parent/dst/dir/subdir" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_merging_dir/atom/darwin.json b/test/scenarios/move_merging_dir/atom/darwin.json new file mode 100644 index 000000000..76cf39853 --- /dev/null +++ b/test/scenarios/move_merging_dir/atom/darwin.json @@ -0,0 +1,54 @@ +[ + [ + { + "action": "modified", + "kind": "file", + "path": "dst/dir/file" + }, + { + "action": "created", + "kind": "file", + "path": "dst/dir/file2" + }, + { + "action": "modified", + "kind": "file", + "path": "dst/dir/subdir/file" + }, + { + "action": "created", + "kind": "file", + "path": "dst/dir/subdir/file6" + }, + { + "action": "deleted", + "kind": "file", + "path": "src/dir/file" + }, + { + "action": "deleted", + "kind": "file", + "path": "src/dir/file2" + }, + { + "action": "deleted", + "kind": "file", + "path": "src/dir/subdir/file6" + }, + { + "action": "deleted", + "kind": "file", + "path": "src/dir/subdir/file" + }, + { + "action": "deleted", + "kind": "directory", + "path": "src/dir/subdir" + }, + { + "action": "deleted", + "kind": "directory", + "path": "src/dir" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_overwriting_dir/atom/darwin.json b/test/scenarios/move_overwriting_dir/atom/darwin.json new file mode 100644 index 000000000..fcf1ed7f2 --- /dev/null +++ b/test/scenarios/move_overwriting_dir/atom/darwin.json @@ -0,0 +1,373 @@ +[ + [ + { + "action": "deleted", + "kind": "file", + "path": "dst/dir/file" + }, + { + "action": "created", + "kind": "file", + "path": "dst/dir/file" + }, + { + "action": "deleted", + "kind": "file", + "path": "dst/dir/file3" + }, + { + "action": "deleted", + "kind": "file", + "path": "dst/dir/subdir/file5" + }, + { + "action": "deleted", + "kind": "file", + "path": "dst/dir/subdir/file" + }, + { + "action": "deleted", + "kind": "directory", + "path": "dst/dir/subdir" + }, + { + "action": "created", + "kind": "directory", + "path": "dst/dir/subdir" + }, + { + "action": "deleted", + "kind": "directory", + "path": "dst/dir" + }, + { + "action": "created", + "kind": "directory", + "path": "dst/dir" + } + ], + [ + { + "action": "deleted", + "kind": "directory", + "path": "dst/dir/subdir" + }, + { + "action": "created", + "kind": "directory", + "path": "dst/dir/subdir" + }, + { + "action": "deleted", + "kind": "file", + "path": "dst/dir/file" + }, + { + "action": "created", + "kind": "file", + "path": "dst/dir/file" + }, + { + "action": "created", + "kind": "file", + "path": "dst/dir/file2" + } + ], + [], + [ + { + "action": "scan", + "path": "dst/dir/file", + "kind": "file", + "stats": { + "dev": 16777226, + "mode": 33188, + "nlink": 1, + "uid": 501, + "gid": 20, + "rdev": 0, + "blksize": 4194304, + "ino": 8600863062, + "size": 8, + "blocks": 8, + "atimeMs": 1554478389099.2615, + "mtimeMs": 1554478389107.9155, + "ctimeMs": 1554478389109.4739, + "birthtimeMs": 1554478389099.2615, + "atime": "2019-04-05T15:33:09.099Z", + "mtime": "2019-04-05T15:33:09.108Z", + "ctime": "2019-04-05T15:33:09.109Z", + "birthtime": "2019-04-05T15:33:09.099Z" + } + }, + { + "action": "scan", + "path": "dst/dir/file2", + "kind": "file", + "stats": { + "dev": 16777226, + "mode": 33188, + "nlink": 1, + "uid": 501, + "gid": 20, + "rdev": 0, + "blksize": 4194304, + "ino": 8600863063, + "size": 8, + "blocks": 8, + "atimeMs": 1554478389099.4941, + "mtimeMs": 1554478389108.0127, + "ctimeMs": 1554478389109.535, + "birthtimeMs": 1554478389099.4941, + "atime": "2019-04-05T15:33:09.099Z", + "mtime": "2019-04-05T15:33:09.108Z", + "ctime": "2019-04-05T15:33:09.110Z", + "birthtime": "2019-04-05T15:33:09.099Z" + } + }, + { + "action": "scan", + "path": "dst/dir/subdir", + "kind": "directory", + "stats": { + "dev": 16777226, + "mode": 16877, + "nlink": 5, + "uid": 501, + "gid": 20, + "rdev": 0, + "blksize": 4194304, + "ino": 8600863064, + "size": 160, + "blocks": 0, + "atimeMs": 1554478389111.253, + "mtimeMs": 1554478389111.886, + "ctimeMs": 1554478389111.886, + "birthtimeMs": 1554478389099.6606, + "atime": "2019-04-05T15:33:09.111Z", + "mtime": "2019-04-05T15:33:09.112Z", + "ctime": "2019-04-05T15:33:09.112Z", + "birthtime": "2019-04-05T15:33:09.100Z" + } + } + ], + [ + { + "action": "scan", + "path": "dst/dir/subdir/file", + "kind": "file", + "stats": { + "dev": 16777226, + "mode": 33188, + "nlink": 1, + "uid": 501, + "gid": 20, + "rdev": 0, + "blksize": 4194304, + "ino": 8600863065, + "size": 8, + "blocks": 8, + "atimeMs": 1554478389111.7083, + "mtimeMs": 1554478389113.0225, + "ctimeMs": 1554478389114.839, + "birthtimeMs": 1554478389111.7083, + "atime": "2019-04-05T15:33:09.112Z", + "mtime": "2019-04-05T15:33:09.113Z", + "ctime": "2019-04-05T15:33:09.115Z", + "birthtime": "2019-04-05T15:33:09.112Z" + } + }, + { + "action": "scan", + "path": "dst/dir/subdir/file6", + "kind": "file", + "stats": { + "dev": 16777226, + "mode": 33188, + "nlink": 1, + "uid": 501, + "gid": 20, + "rdev": 0, + "blksize": 4194304, + "ino": 8600863066, + "size": 8, + "blocks": 8, + "atimeMs": 1554478389111.8313, + "mtimeMs": 1554478389113.162, + "ctimeMs": 1554478389114.8503, + "birthtimeMs": 1554478389111.8313, + "atime": "2019-04-05T15:33:09.112Z", + "mtime": "2019-04-05T15:33:09.113Z", + "ctime": "2019-04-05T15:33:09.115Z", + "birthtime": "2019-04-05T15:33:09.112Z" + } + }, + { + "action": "scan", + "path": "dst/dir/subdir/subsub", + "kind": "directory", + "stats": { + "dev": 16777226, + "mode": 16877, + "nlink": 2, + "uid": 501, + "gid": 20, + "rdev": 0, + "blksize": 4194304, + "ino": 8600863067, + "size": 64, + "blocks": 0, + "atimeMs": 1554478389111.8752, + "mtimeMs": 1554478389111.8752, + "ctimeMs": 1554478389112.7273, + "birthtimeMs": 1554478389111.8752, + "atime": "2019-04-05T15:33:09.112Z", + "mtime": "2019-04-05T15:33:09.112Z", + "ctime": "2019-04-05T15:33:09.113Z", + "birthtime": "2019-04-05T15:33:09.112Z" + } + } + ], + [ + { + "action": "scan", + "path": "dst/dir/subdir/file", + "kind": "file", + "stats": { + "dev": 16777226, + "mode": 33188, + "nlink": 1, + "uid": 501, + "gid": 20, + "rdev": 0, + "blksize": 4194304, + "ino": 8600863065, + "size": 8, + "blocks": 8, + "atimeMs": 1554478389111.7083, + "mtimeMs": 1554478389113.0225, + "ctimeMs": 1554478389114.839, + "birthtimeMs": 1554478389111.7083, + "atime": "2019-04-05T15:33:09.112Z", + "mtime": "2019-04-05T15:33:09.113Z", + "ctime": "2019-04-05T15:33:09.115Z", + "birthtime": "2019-04-05T15:33:09.112Z" + } + }, + { + "action": "scan", + "path": "dst/dir/subdir/file6", + "kind": "file", + "stats": { + "dev": 16777226, + "mode": 33188, + "nlink": 1, + "uid": 501, + "gid": 20, + "rdev": 0, + "blksize": 4194304, + "ino": 8600863066, + "size": 8, + "blocks": 8, + "atimeMs": 1554478389111.8313, + "mtimeMs": 1554478389113.162, + "ctimeMs": 1554478389114.8503, + "birthtimeMs": 1554478389111.8313, + "atime": "2019-04-05T15:33:09.112Z", + "mtime": "2019-04-05T15:33:09.113Z", + "ctime": "2019-04-05T15:33:09.115Z", + "birthtime": "2019-04-05T15:33:09.112Z" + } + }, + { + "action": "scan", + "path": "dst/dir/subdir/subsub", + "kind": "directory", + "stats": { + "dev": 16777226, + "mode": 16877, + "nlink": 2, + "uid": 501, + "gid": 20, + "rdev": 0, + "blksize": 4194304, + "ino": 8600863067, + "size": 64, + "blocks": 0, + "atimeMs": 1554478389111.8752, + "mtimeMs": 1554478389111.8752, + "ctimeMs": 1554478389112.7273, + "birthtimeMs": 1554478389111.8752, + "atime": "2019-04-05T15:33:09.112Z", + "mtime": "2019-04-05T15:33:09.112Z", + "ctime": "2019-04-05T15:33:09.113Z", + "birthtime": "2019-04-05T15:33:09.112Z" + } + } + ], + [], + [], + [ + { + "action": "created", + "kind": "directory", + "path": "dst/dir/subdir/subsub" + }, + { + "action": "created", + "kind": "file", + "path": "dst/dir/subdir/file" + }, + { + "action": "deleted", + "kind": "file", + "path": "dst/dir/subdir/file" + }, + { + "action": "created", + "kind": "file", + "path": "dst/dir/subdir/file" + }, + { + "action": "created", + "kind": "file", + "path": "dst/dir/subdir/file6" + }, + { + "action": "deleted", + "kind": "file", + "path": "src/dir/file" + }, + { + "action": "deleted", + "kind": "file", + "path": "src/dir/file2" + }, + { + "action": "deleted", + "kind": "file", + "path": "src/dir/subdir/file6" + }, + { + "action": "deleted", + "kind": "file", + "path": "src/dir/subdir/file" + }, + { + "action": "deleted", + "kind": "directory", + "path": "src/dir/subdir/subsub" + }, + { + "action": "deleted", + "kind": "directory", + "path": "src/dir/subdir" + }, + { + "action": "deleted", + "kind": "directory", + "path": "src/dir" + } + ], + [] +] \ No newline at end of file diff --git a/test/scenarios/move_overwriting_file/atom/darwin.json b/test/scenarios/move_overwriting_file/atom/darwin.json new file mode 100644 index 000000000..7351d57b2 --- /dev/null +++ b/test/scenarios/move_overwriting_file/atom/darwin.json @@ -0,0 +1,17 @@ +[ + [ + { + "action": "renamed", + "kind": "file", + "path": "dst/file", + "oldPath": "src/file" + } + ], + [ + { + "action": "deleted", + "kind": "file", + "path": "dst/file" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_two_dirs/atom/darwin.json b/test/scenarios/move_two_dirs/atom/darwin.json new file mode 100644 index 000000000..3cf5041ee --- /dev/null +++ b/test/scenarios/move_two_dirs/atom/darwin.json @@ -0,0 +1,18 @@ +[ + [ + { + "action": "renamed", + "kind": "directory", + "path": "dst/dir1", + "oldPath": "src/dir1" + } + ], + [ + { + "action": "renamed", + "kind": "directory", + "path": "dst/dir2", + "oldPath": "src/dir2" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_two_dirs_same_prefix/atom/darwin.json b/test/scenarios/move_two_dirs_same_prefix/atom/darwin.json new file mode 100644 index 000000000..577d01e83 --- /dev/null +++ b/test/scenarios/move_two_dirs_same_prefix/atom/darwin.json @@ -0,0 +1,17 @@ +[ + [ + { + "action": "renamed", + "kind": "directory", + "path": "dst/dir1", + "oldPath": "src/dir1" + } + ], + [ + { + "action": "deleted", + "kind": "directory", + "path": "src/dir12" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/move_two_files/atom/darwin.json b/test/scenarios/move_two_files/atom/darwin.json new file mode 100644 index 000000000..f3f32d73f --- /dev/null +++ b/test/scenarios/move_two_files/atom/darwin.json @@ -0,0 +1,18 @@ +[ + [ + { + "action": "renamed", + "kind": "file", + "path": "dst/file1", + "oldPath": "src/file1" + } + ], + [ + { + "action": "renamed", + "kind": "file", + "path": "dst/file2", + "oldPath": "src/file2" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/rename_identical/atom/darwin.json b/test/scenarios/rename_identical/atom/darwin.json new file mode 100644 index 000000000..4f7a89a33 --- /dev/null +++ b/test/scenarios/rename_identical/atom/darwin.json @@ -0,0 +1,38 @@ +[ + [ + { + "action": "modified", + "kind": "file", + "path": "file-case" + }, + { + "action": "modified", + "kind": "file", + "path": "file-nfc-to-nfd-é" + } + ], + [ + { + "action": "created", + "kind": "file", + "path": "file-nfc-to-nfd-é" + }, + { + "action": "created", + "kind": "directory", + "path": "dir-nfc-to-nfd-é" + }, + { + "action": "created", + "kind": "file", + "path": "FILE-CASE" + }, + { + "action": "created", + "kind": "directory", + "path": "DIR-CASE" + } + ], + [], + [] +] \ No newline at end of file diff --git a/test/scenarios/rename_identical_local_loopback/atom/darwin.json b/test/scenarios/rename_identical_local_loopback/atom/darwin.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/test/scenarios/rename_identical_local_loopback/atom/darwin.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/scenarios/rename_subdir_after_parent/atom/darwin.json b/test/scenarios/rename_subdir_after_parent/atom/darwin.json new file mode 100644 index 000000000..aedf3aa69 --- /dev/null +++ b/test/scenarios/rename_subdir_after_parent/atom/darwin.json @@ -0,0 +1,26 @@ +[ + [ + { + "action": "renamed", + "kind": "directory", + "path": "parent-2", + "oldPath": "parent" + } + ], + [ + { + "action": "renamed", + "kind": "directory", + "path": "parent-2/subdir-2", + "oldPath": "parent-2/subdir" + } + ], + [ + { + "action": "renamed", + "kind": "directory", + "path": "parent-2/subdir-2/subsubdir-2", + "oldPath": "parent-2/subdir-2/subsubdir" + } + ] +] \ No newline at end of file diff --git a/test/scenarios/trash_dir_with_content/atom/darwin.json b/test/scenarios/trash_dir_with_content/atom/darwin.json new file mode 100644 index 000000000..727f2f8d1 --- /dev/null +++ b/test/scenarios/trash_dir_with_content/atom/darwin.json @@ -0,0 +1,24 @@ +[ + [ + { + "action": "deleted", + "kind": "directory", + "path": "parent/dir/empty-subdir" + }, + { + "action": "deleted", + "kind": "file", + "path": "parent/dir/subdir/file" + }, + { + "action": "deleted", + "kind": "directory", + "path": "parent/dir/subdir" + }, + { + "action": "deleted", + "kind": "directory", + "path": "parent/dir" + } + ] +] \ No newline at end of file From 1c2fb61d0f612f325a40d6e17ac78f144916b31e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Nicouleaud?= Date: Mon, 20 May 2019 16:20:32 +0200 Subject: [PATCH 4/6] test/unit/config: Fix test descriptions --- test/unit/config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/config.js b/test/unit/config.js index fe05dd031..0b78f203a 100644 --- a/test/unit/config.js +++ b/test/unit/config.js @@ -324,7 +324,7 @@ describe('core/config', function() { ) }) - it('is chokidar on Windows', () => { + it('is atom on Windows', () => { should(config.platformDefaultWatcherType('win32')).equal('atom') }) @@ -332,7 +332,7 @@ describe('core/config', function() { should(config.platformDefaultWatcherType('darwin')).equal('chokidar') }) - it('is chokidar on Linux', () => { + it('is atom on Linux', () => { should(config.platformDefaultWatcherType('linux')).equal('atom') }) }) From b9ff4fe78a30932e5d5bb9d328647f676fcc14c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Nicouleaud?= Date: Thu, 4 Apr 2019 15:44:31 +0200 Subject: [PATCH 5/6] [FIXME] core/config: Use atom watcher by default on macOS We probably don't want to do this at first. Just merge macOS support into master, so we can publish a new release. And test the new combo by enabling it in config file. --- core/config.js | 11 +++-------- test/unit/config.js | 4 ++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/core/config.js b/core/config.js index 1c3c023d3..1314ed126 100644 --- a/core/config.js +++ b/core/config.js @@ -230,12 +230,12 @@ function loadOrDeleteFile(configPath /*: string */) /*: FileConfig */ { /** Detect which local watcher will be used. */ function watcherType( fileConfig /*: FileConfig */ = {}, - { env, platform } /*: * */ = process + { env } /*: * */ = process ) /*: WatcherType */ { return ( fileWatcherType(fileConfig) || environmentWatcherType(env) || - platformDefaultWatcherType(platform) + platformDefaultWatcherType() ) } @@ -250,12 +250,7 @@ function environmentWatcherType( return validateWatcherType(COZY_FS_WATCHER) } -function platformDefaultWatcherType( - platform /*: string */ = process.platform -) /*: WatcherType */ { - if (platform === 'darwin') { - return 'chokidar' - } +function platformDefaultWatcherType() /*: WatcherType */ { return 'atom' } diff --git a/test/unit/config.js b/test/unit/config.js index 0b78f203a..3091fe319 100644 --- a/test/unit/config.js +++ b/test/unit/config.js @@ -328,8 +328,8 @@ describe('core/config', function() { should(config.platformDefaultWatcherType('win32')).equal('atom') }) - it('is chokidar on macOS', () => { - should(config.platformDefaultWatcherType('darwin')).equal('chokidar') + it('is atom on macOS', () => { + should(config.platformDefaultWatcherType('darwin')).equal('atom') }) it('is atom on Linux', () => { From 2b78bacca469c843919a7d2865b10d97756d446b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Nicouleaud?= Date: Mon, 20 May 2019 16:31:41 +0200 Subject: [PATCH 6/6] [FIXME] core/local/steps/producer: macOS LocalEventBuffer Temporary proof-of-concept. To be reimplemented as a macOS specific step just after producer. (captures would take the output of this new step) --- core/local/atom/producer.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/core/local/atom/producer.js b/core/local/atom/producer.js index b67e4d080..b454a15f1 100644 --- a/core/local/atom/producer.js +++ b/core/local/atom/producer.js @@ -12,11 +12,12 @@ const watcher = require('@atom/watcher') const Channel = require('./channel') const { INITIAL_SCAN_DONE } = require('./event') const defaultStater = require('../stater') +const LocalEventBuffer = require('../chokidar/event_buffer') const logger = require('../../utils/logger') /*:: import type { Ignore } from '../../ignore' -import type { AtomEvent } from './event' +import type { AtomBatch, AtomEvent } from './event' export type Scanner = (string) => Promise */ @@ -61,12 +62,21 @@ class Producer { syncPath: string ignore: Ignore watcher: * + macOSBuffer: ?LocalEventBuffer */ constructor(opts /*: { syncPath: string, ignore: Ignore } */) { this.channel = new Channel() this.syncPath = opts.syncPath this.ignore = opts.ignore this.watcher = null + if (process.platform === 'darwin') { + const timeoutInMs = process.env.NODE_ENV === 'test' ? 1000 : 10000 + this.macOSBuffer = new LocalEventBuffer(timeoutInMs, batches => { + for (const batch of batches) { + this.process(batch) + } + }) + } autoBind(this) } @@ -90,10 +100,15 @@ class Producer { * the recursive option. */ async start() { + const macOSBuffer = this.macOSBuffer + const onEventBatch = macOSBuffer + ? macOSBuffer.push.bind(macOSBuffer) + : this.process + this.watcher = await watcher.watchPath( this.syncPath, { recursive: true }, - this.process + onEventBatch ) log.info(`Now watching ${this.syncPath}`) if (process.platform === 'linux') {