Mercurial > public > mercurial-scm > hg-stable
annotate rust/hg-core/src/copy_tracing/tests.rs @ 52552:66e34bc44280
rhg: set the expected temp file permissions (0o666 minus umask)
This continues the theme of a48c688d3e80, and fixes the bug #6375,
which was causing some problems for us, where a non-group-readable
file can't be copied, which breaks some tools that copy the repo.
This affects both the `checkexec` file and the temporary file we
use for filesystem time measurement, since either of these files
remaining on disk can cause this problem, and the 0666 permissions
are just the better default here.
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Thu, 05 Dec 2024 13:17:32 +0000 |
parents | 4c5f6e95df84 |
children |
rev | line source |
---|---|
46697
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
1 use super::*; |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
2 |
50990
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
3 /// Shorthand to reduce boilerplate when creating [`Revision`] for testing |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
4 macro_rules! R { |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
5 ($revision:literal) => { |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
6 Revision($revision) |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
7 }; |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
8 } |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
9 |
46697
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
10 /// Unit tests for: |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
11 /// |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
12 /// ```ignore |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
13 /// fn compare_value( |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
14 /// current_merge: Revision, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
15 /// merge_case_for_dest: impl Fn() -> MergeCase, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
16 /// src_minor: &CopySource, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
17 /// src_major: &CopySource, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
18 /// ) -> (MergePick, /* overwrite: */ bool) |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
19 /// ``` |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
20 #[test] |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
21 fn test_compare_value() { |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
22 // The `compare_value!` macro calls the `compare_value` function with |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
23 // arguments given in pseudo-syntax: |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
24 // |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
25 // * For `merge_case_for_dest` it takes a plain `MergeCase` value instead |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
26 // of a closure. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
27 // * `CopySource` values are represented as `(rev, path, overwritten)` |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
28 // tuples of type `(Revision, Option<PathToken>, OrdSet<Revision>)`. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
29 // * `PathToken` is an integer not read by `compare_value`. It only checks |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
30 // for `Some(_)` indicating a file copy v.s. `None` for a file deletion. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
31 // * `OrdSet<Revision>` is represented as a Python-like set literal. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
32 |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
33 use MergeCase::*; |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
34 use MergePick::*; |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
35 |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
36 assert_eq!( |
50990
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
37 compare_value!( |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
38 R!(1), |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
39 Normal, |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
40 (R!(1), None, { R!(1) }), |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
41 (R!(1), None, { R!(1) }) |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
42 ), |
46697
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
43 (Any, false) |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
44 ); |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
45 } |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
46 |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
47 /// Unit tests for: |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
48 /// |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
49 /// ```ignore |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
50 /// fn merge_copies_dict( |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
51 /// path_map: &TwoWayPathMap, // Not visible in test cases |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
52 /// current_merge: Revision, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
53 /// minor: InternalPathCopies, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
54 /// major: InternalPathCopies, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
55 /// get_merge_case: impl Fn(&HgPath) -> MergeCase + Copy, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
56 /// ) -> InternalPathCopies |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
57 /// ``` |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
58 #[test] |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
59 fn test_merge_copies_dict() { |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
60 // The `merge_copies_dict!` macro calls the `merge_copies_dict` function |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
61 // with arguments given in pseudo-syntax: |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
62 // |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
63 // * `TwoWayPathMap` and path tokenization are implicitly taken care of. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
64 // All paths are given as string literals. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
65 // * Key-value maps are represented with `{key1 => value1, key2 => value2}` |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
66 // pseudo-syntax. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
67 // * `InternalPathCopies` is a map of copy destination path keys to |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
68 // `CopySource` values. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
69 // - `CopySource` is represented as a `(rev, source_path, overwritten)` |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
70 // tuple of type `(Revision, Option<Path>, OrdSet<Revision>)`. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
71 // - Unlike in `test_compare_value`, source paths are string literals. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
72 // - `OrdSet<Revision>` is again represented as a Python-like set |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
73 // literal. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
74 // * `get_merge_case` is represented as a map of copy destination path to |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
75 // `MergeCase`. The default for paths not in the map is |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
76 // `MergeCase::Normal`. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
77 // |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
78 // `internal_path_copies!` creates an `InternalPathCopies` value with the |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
79 // same pseudo-syntax as in `merge_copies_dict!`. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
80 |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
81 use MergeCase::*; |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
82 |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
83 assert_eq!( |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
84 merge_copies_dict!( |
50990
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
85 R!(1), |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
86 {"foo" => (R!(1), None, {})}, |
46697
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
87 {}, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
88 {"foo" => Merged} |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
89 ), |
50990
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
90 internal_path_copies!("foo" => (R!(1), None, {})) |
46697
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
91 ); |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
92 } |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
93 |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
94 /// Unit tests for: |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
95 /// |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
96 /// ```ignore |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
97 /// impl CombineChangesetCopies { |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
98 /// fn new(children_count: HashMap<Revision, usize>) -> Self |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
99 /// |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
100 /// // Called repeatedly: |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
101 /// fn add_revision_inner<'a>( |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
102 /// &mut self, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
103 /// rev: Revision, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
104 /// p1: Revision, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
105 /// p2: Revision, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
106 /// copy_actions: impl Iterator<Item = Action<'a>>, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
107 /// get_merge_case: impl Fn(&HgPath) -> MergeCase + Copy, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
108 /// ) |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
109 /// |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
110 /// fn finish(mut self, target_rev: Revision) -> PathCopies |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
111 /// } |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
112 /// ``` |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
113 #[test] |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
114 fn test_combine_changeset_copies() { |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
115 // `combine_changeset_copies!` creates a `CombineChangesetCopies` with |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
116 // `new`, then calls `add_revision_inner` repeatedly, then calls `finish` |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
117 // for its return value. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
118 // |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
119 // All paths given as string literals. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
120 // |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
121 // * Key-value maps are represented with `{key1 => value1, key2 => value2}` |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
122 // pseudo-syntax. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
123 // * `children_count` is a map of revision numbers to count of children in |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
124 // the DAG. It includes all revisions that should be considered by the |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
125 // algorithm. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
126 // * Calls to `add_revision_inner` are represented as an array of anonymous |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
127 // structs with named fields, one pseudo-struct per call. |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
128 // |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
129 // `path_copies!` creates a `PathCopies` value, a map of copy destination |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
130 // keys to copy source values. Note: the arrows for map literal syntax |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
131 // point **backwards** compared to the logical direction of copy! |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
132 |
50010
750409505286
rust-clippy: merge "revlog" module definition and struct implementation
Rapha?l Gom?s <rgomes@octobus.net>
parents:
46697
diff
changeset
|
133 use crate::revlog::NULL_REVISION as NULL; |
46697
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
134 use Action::*; |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
135 use MergeCase::*; |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
136 |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
137 assert_eq!( |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
138 combine_changeset_copies!( |
50990
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
139 { R!(1) => 1, R!(2) => 1 }, |
46697
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
140 [ |
50990
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
141 { |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
142 rev: R!(1), |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
143 p1: NULL, |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
144 p2: NULL, |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
145 actions: [], |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
146 merge_cases: {}, |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
147 }, |
46697
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
148 { |
50990
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
149 rev: R!(2), |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
150 p1: NULL, |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
151 p2: NULL, |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
152 actions: [], |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
153 merge_cases: {}, |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
154 }, |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
155 { |
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
156 rev: R!(3), p1: R!(1), p2: R!(2), |
46697
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
157 actions: [CopiedFromP1("destination.txt", "source.txt")], |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
158 merge_cases: {"destination.txt" => Merged}, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
159 }, |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
160 ], |
50990
4c5f6e95df84
rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50010
diff
changeset
|
161 R!(3), |
46697
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
162 ), |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
163 path_copies!("destination.txt" => "source.txt") |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
164 ); |
fa21633af201
copies-rust: add a macro-based unit-testing framework
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
165 } |