@@ -9,6 +9,7 @@ module Usage = {
99 ++ CmdLine . pathToExtractExe
1010 ++ " [path...]
1111 -v shows the program version
12+ --allow-duplicates allows entities with identical `id` props if `defaultMessage` props are identical as well
1213 -help Display this list of options
1314 --help Display this list of options
1415" ;
@@ -69,7 +70,34 @@ module Extract = {
6970
7071 let testExtractPartial = () => checkRes("test/test1/subdir/Test_1_2.re test/test2" , (partial, "" ));
7172
72- let testSet = [ ("Extract full" , ` Quick , testExtractFull), ("Extract partial" , ` Quick , testExtractPartial)] ;
73+ let dup = {| [
74+ { "id": "test3.msg1.1", "defaultMessage": "This is message 1.1" },
75+ { "id": "test3.msg1.2", "defaultMessage": "This is message 1.2" },
76+ { "id": "test3.msg1.3", "defaultMessage": "This is message 1.3" }
77+ ]
78+ |} ;
79+
80+ let testExtractDup = () => checkRes("--allow-duplicates test/test3/Test_1_1.re test/test3/Test_1_2.re" , (dup, "" ));
81+
82+ let dupWithoutFlagError = "Error: duplicate message id: test3.msg1.1\n " ;
83+
84+ let testExtractDupWithoutFlagError = () => checkRes("test/test3/Test_1_1.re test/test3/Test_1_2.re" , ("" , dupWithoutFlagError));
85+
86+ let dupWithDifferentDefaultMessageError = "Error: duplicate message id: test3.msg1.1 with different default messages\n " ;
87+
88+ let testExtractDupWithDifferentDefaultMessageError = () =>
89+ checkRes(
90+ "--allow-duplicates test/test3/Test_1_1.re test/test3/Test_1_2.re test/test3/Test_1_3.re" ,
91+ ("" , dupWithDifferentDefaultMessageError),
92+ );
93+
94+ let testSet = [
95+ ("Extract full" , ` Quick , testExtractFull),
96+ ("Extract partial" , ` Quick , testExtractPartial),
97+ ("Extract dup" , ` Quick , testExtractDup),
98+ ("Extract dup without flag error" , ` Quick , testExtractDupWithoutFlagError),
99+ ("Extract dup with different defaultMessage error" , ` Quick , testExtractDupWithDifferentDefaultMessageError),
100+ ] ;
73101};
74102
75103let () =
0 commit comments