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

#2291. Update Link.create() tests according to the documentation #2299

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions LibTest/io/Link/create_A01_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,36 @@
/// String target, {
/// bool recursive: false
/// })
/// Creates a symbolic link. Returns a Future<Link> that completes with the link
/// when it has been created. If the link exists, the future will complete with
/// an error.
/// Creates a symbolic link in the file system.
///
/// If recursive is false, the default, the link is created only if all
/// directories in its path exist. If recursive is true, all non-existing path
/// components are created. The directories in the path of target are not
/// affected, unless they are also in path.
/// The created link will point to the path at `target`, whether that path
/// exists or not.
///
/// On the Windows platform, this will only work with directories, and the target
/// directory must exist. The link will be created as a Junction. Only absolute
/// links will be created, and relative paths to the target will be converted to
/// absolute paths by joining them with the path of the directory the link is
/// contained in.
/// Returns a `Future<Link>` that completes with the link when it has been
/// created. If the link path already exists, the future will complete with an
/// error.
///
/// On other platforms, the posix symlink() call is used to make a symbolic link
/// containing the string target. If target is a relative path, it will be
/// interpreted relative to the directory containing the link.
/// @description Checks that this method creates the link
/// If `recursive` is `false`, the default, the link is created only if all
/// directories in its path exist. If `recursive` is `true`, all non-existing
/// parent paths are created first. The directories in the path of target are
/// not affected, unless they are also in [path].
///
/// On the Windows platform, this call will create a true symbolic link instead
/// of a junction. The link represents a file or directory and does not change
/// its type after creation. If `target` exists then the type of the link will
/// match the type `target`, otherwise a file symlink is created.
///
/// @note The test should run with the Administrator priveleges on Windows.
/// Dart API Spec reads:
/// In order to create a symbolic link on Windows, Dart must be run in
/// Administrator mode or the system must have Developer Mode enabled, otherwise
/// a FileSystemException will be raised with ERROR_PRIVILEGE_NOT_HELD set as
/// the errno when this call is made.
/// a [FileSystemException] will be raised with `ERROR_PRIVILEGE_NOT_HELD` set
/// as the errno when this call is made.
///
/// On other platforms, the POSIX `symlink()` call is used to make a symbolic
/// link containing the string `target`. If `target` is a relative path, it will
/// be interpreted relative to the directory containing the link.
///
/// @description Checks that this method creates the link. Test [Directory] as
/// a target
/// @author sgrekhov@unipro.ru

import "dart:io";
Expand All @@ -50,6 +53,7 @@ _main(Directory sandbox) async {
await link.create(target.path).then((Link created) {
Expect.isTrue(created.existsSync());
Expect.equals(link.path, created.path);
Expect.equals(target.path, created.targetSync());
eernstg marked this conversation as resolved.
Show resolved Hide resolved
asyncEnd();
});
}
59 changes: 59 additions & 0 deletions LibTest/io/Link/create_A01_t02.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion Future<Link> create(
/// String target, {
/// bool recursive: false
/// })
/// Creates a symbolic link in the file system.
///
/// The created link will point to the path at `target`, whether that path
/// exists or not.
///
/// Returns a `Future<Link>` that completes with the link when it has been
/// created. If the link path already exists, the future will complete with an
/// error.
///
/// If `recursive` is `false`, the default, the link is created only if all
/// directories in its path exist. If `recursive` is `true`, all non-existing
/// parent paths are created first. The directories in the path of target are
/// not affected, unless they are also in [path].
///
/// On the Windows platform, this call will create a true symbolic link instead
/// of a junction. The link represents a file or directory and does not change
/// its type after creation. If `target` exists then the type of the link will
/// match the type `target`, otherwise a file symlink is created.
///
/// In order to create a symbolic link on Windows, Dart must be run in
/// Administrator mode or the system must have Developer Mode enabled, otherwise
/// a [FileSystemException] will be raised with `ERROR_PRIVILEGE_NOT_HELD` set
/// as the errno when this call is made.
///
/// On other platforms, the POSIX `symlink()` call is used to make a symbolic
/// link containing the string `target`. If `target` is a relative path, it will
/// be interpreted relative to the directory containing the link.
///
/// @description Checks that this method creates the link. Test [File] as a
/// target
/// @author sgrekhov22@gmail.com

import "dart:io";
import "../../../Utils/expect.dart";
import "../file_utils.dart";

main() async {
await inSandbox(_main);
}

_main(Directory sandbox) async {
File target = getTempFileSync(parent: sandbox);
Link link = new Link(getTempFilePath(parent: sandbox));
asyncStart();
await link.create(target.path).then((Link created) {
Expect.isTrue(created.existsSync());
Expect.equals(link.path, created.path);
Expect.equals(target.path, created.targetSync());
asyncEnd();
});
}
59 changes: 59 additions & 0 deletions LibTest/io/Link/create_A01_t03.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion Future<Link> create(
/// String target, {
/// bool recursive: false
/// })
/// Creates a symbolic link in the file system.
///
/// The created link will point to the path at `target`, whether that path
/// exists or not.
///
/// Returns a `Future<Link>` that completes with the link when it has been
/// created. If the link path already exists, the future will complete with an
/// error.
///
/// If `recursive` is `false`, the default, the link is created only if all
/// directories in its path exist. If `recursive` is `true`, all non-existing
/// parent paths are created first. The directories in the path of target are
/// not affected, unless they are also in [path].
///
/// On the Windows platform, this call will create a true symbolic link instead
/// of a junction. The link represents a file or directory and does not change
/// its type after creation. If `target` exists then the type of the link will
/// match the type `target`, otherwise a file symlink is created.
///
/// In order to create a symbolic link on Windows, Dart must be run in
/// Administrator mode or the system must have Developer Mode enabled, otherwise
/// a [FileSystemException] will be raised with `ERROR_PRIVILEGE_NOT_HELD` set
/// as the errno when this call is made.
///
/// On other platforms, the POSIX `symlink()` call is used to make a symbolic
/// link containing the string `target`. If `target` is a relative path, it will
/// be interpreted relative to the directory containing the link.
///
/// @description Checks that this method creates the link. Test another [Link]
/// as a target
/// @author sgrekhov22@gmail.com

import "dart:io";
import "../../../Utils/expect.dart";
import "../file_utils.dart";

main() async {
await inSandbox(_main);
}

_main(Directory sandbox) async {
Link target = getTempLinkSync(parent: sandbox);
Link link = new Link(getTempFilePath(parent: sandbox));
asyncStart();
await link.create(target.path).then((Link created) {
Expect.isTrue(created.existsSync());
Expect.equals(link.path, created.path);
Expect.equals(target.path, created.targetSync());
asyncEnd();
});
}
59 changes: 59 additions & 0 deletions LibTest/io/Link/create_A01_t04.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion Future<Link> create(
/// String target, {
/// bool recursive: false
/// })
/// Creates a symbolic link in the file system.
///
/// The created link will point to the path at `target`, whether that path
/// exists or not.
///
/// Returns a `Future<Link>` that completes with the link when it has been
/// created. If the link path already exists, the future will complete with an
/// error.
///
/// If `recursive` is `false`, the default, the link is created only if all
/// directories in its path exist. If `recursive` is `true`, all non-existing
/// parent paths are created first. The directories in the path of target are
/// not affected, unless they are also in [path].
///
/// On the Windows platform, this call will create a true symbolic link instead
/// of a junction. The link represents a file or directory and does not change
/// its type after creation. If `target` exists then the type of the link will
/// match the type `target`, otherwise a file symlink is created.
///
/// In order to create a symbolic link on Windows, Dart must be run in
/// Administrator mode or the system must have Developer Mode enabled, otherwise
/// a [FileSystemException] will be raised with `ERROR_PRIVILEGE_NOT_HELD` set
/// as the errno when this call is made.
///
/// On other platforms, the POSIX `symlink()` call is used to make a symbolic
/// link containing the string `target`. If `target` is a relative path, it will
/// be interpreted relative to the directory containing the link.
///
/// @description Checks that this method creates the link. Test not existing
/// entity as a target
/// @author sgrekhov22@gmail.com

import "dart:io";
import "../../../Utils/expect.dart";
import "../file_utils.dart";

main() async {
await inSandbox(_main);
}

_main(Directory sandbox) async {
String target = getTempFilePath(parent: sandbox);
Link link = new Link(getTempFilePath(parent: sandbox));
asyncStart();
await link.create(target).then((Link created) {
Expect.isTrue(created.existsSync());
Expect.equals(link.path, created.path);
Expect.equals(target, created.targetSync());
asyncEnd();
});
}
44 changes: 27 additions & 17 deletions LibTest/io/Link/create_A02_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,36 @@
/// String target, {
/// bool recursive: false
/// })
/// Creates a symbolic link. Returns a Future<Link> that completes with the link
/// when it has been created. If the link exists, the future will complete with
/// an error.
/// Creates a symbolic link in the file system.
///
/// If recursive is false, the default, the link is created only if all
/// directories in its path exist. If recursive is true, all non-existing path
/// components are created. The directories in the path of target are not
/// affected, unless they are also in path.
/// The created link will point to the path at `target`, whether that path
/// exists or not.
///
/// On the Windows platform, this will only work with directories, and the target
/// directory must exist. The link will be created as a Junction. Only absolute
/// links will be created, and relative paths to the target will be converted to
/// absolute paths by joining them with the path of the directory the link is
/// contained in.
/// Returns a `Future<Link>` that completes with the link when it has been
/// created. If the link path already exists, the future will complete with an
/// error.
///
/// On other platforms, the posix symlink() call is used to make a symbolic link
/// containing the string target. If target is a relative path, it will be
/// interpreted relative to the directory containing the link.
/// @description Checks that if recursive is false and there are non-existing
/// path components, then operation fails
/// If `recursive` is `false`, the default, the link is created only if all
/// directories in its path exist. If `recursive` is `true`, all non-existing
/// parent paths are created first. The directories in the path of target are
/// not affected, unless they are also in [path].
///
/// On the Windows platform, this call will create a true symbolic link instead
/// of a junction. The link represents a file or directory and does not change
/// its type after creation. If `target` exists then the type of the link will
/// match the type `target`, otherwise a file symlink is created.
///
/// In order to create a symbolic link on Windows, Dart must be run in
/// Administrator mode or the system must have Developer Mode enabled, otherwise
/// a [FileSystemException] will be raised with `ERROR_PRIVILEGE_NOT_HELD` set
/// as the errno when this call is made.
///
/// On other platforms, the POSIX `symlink()` call is used to make a symbolic
/// link containing the string `target`. If `target` is a relative path, it will
/// be interpreted relative to the directory containing the link.
///
/// @description Checks that if `recursive` is `false` and there are
/// non-existing path components, then operation fails
/// @author sgrekhov@unipro.ru

import "dart:io";
Expand Down
44 changes: 23 additions & 21 deletions LibTest/io/Link/create_A02_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,36 @@
/// String target, {
/// bool recursive: false
/// })
/// Creates a symbolic link. Returns a Future<Link> that completes with the link
/// when it has been created. If the link exists, the future will complete with
/// an error.
/// Creates a symbolic link in the file system.
///
/// If recursive is false, the default, the link is created only if all
/// directories in its path exist. If recursive is true, all non-existing path
/// components are created. The directories in the path of target are not
/// affected, unless they are also in path.
/// The created link will point to the path at `target`, whether that path
/// exists or not.
///
/// On the Windows platform, this will only work with directories, and the target
/// directory must exist. The link will be created as a Junction. Only absolute
/// links will be created, and relative paths to the target will be converted to
/// absolute paths by joining them with the path of the directory the link is
/// contained in.
/// Returns a `Future<Link>` that completes with the link when it has been
/// created. If the link path already exists, the future will complete with an
/// error.
///
/// On other platforms, the posix symlink() call is used to make a symbolic link
/// containing the string target. If target is a relative path, it will be
/// interpreted relative to the directory containing the link.
/// @description Checks that if recursive is true, all non-existing path
/// components are created
/// If `recursive` is `false`, the default, the link is created only if all
/// directories in its path exist. If `recursive` is `true`, all non-existing
/// parent paths are created first. The directories in the path of target are
/// not affected, unless they are also in [path].
///
/// On the Windows platform, this call will create a true symbolic link instead
/// of a junction. The link represents a file or directory and does not change
/// its type after creation. If `target` exists then the type of the link will
/// match the type `target`, otherwise a file symlink is created.
///
/// @note The test should run with the Administrator priveleges on Windows.
/// Dart API Spec reads:
/// In order to create a symbolic link on Windows, Dart must be run in
/// Administrator mode or the system must have Developer Mode enabled, otherwise
/// a FileSystemException will be raised with ERROR_PRIVILEGE_NOT_HELD set as
/// the errno when this call is made.
/// a [FileSystemException] will be raised with `ERROR_PRIVILEGE_NOT_HELD` set
/// as the errno when this call is made.
///
/// On other platforms, the POSIX `symlink()` call is used to make a symbolic
/// link containing the string `target`. If `target` is a relative path, it will
/// be interpreted relative to the directory containing the link.
///
/// @description Checks that if `recursive` is `true`, all non-existing path
/// components are created
/// @author sgrekhov@unipro.ru

import "dart:io";
Expand Down
Loading