From c1a61e0dbc1a1f0bea700909aed307ee74e3d701 Mon Sep 17 00:00:00 2001 From: Alexey Safronov Date: Fri, 21 Oct 2022 17:19:52 +0300 Subject: [PATCH 1/8] Create run.translations.tests.sh --- build/run.translations.tests.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 build/run.translations.tests.sh diff --git a/build/run.translations.tests.sh b/build/run.translations.tests.sh new file mode 100755 index 0000000000..8545a6540c --- /dev/null +++ b/build/run.translations.tests.sh @@ -0,0 +1,8 @@ +rd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +echo "Run script directory:" $dir + +dir=$(builtin cd $rd/../; pwd) + +echo "Root directory:" $dir + +dotnet test $dir/common/Tests/Frontend.Translations.Tests/Frontend.Translations.Tests.csproj --filter "TestCategory=FastRunning" -l:html -r TestsResults \ No newline at end of file From 8d0d536bf602c873e585e94d138b0c50fab02b82 Mon Sep 17 00:00:00 2001 From: Alexey Safronov Date: Fri, 21 Oct 2022 17:21:12 +0300 Subject: [PATCH 2/8] Fix path issues --- .../LocalesTest.cs | 47 +++++++++---------- .../Models/JavaScriptFile.cs | 2 +- .../Models/SpellCheckResult.cs | 12 ++--- .../Models/TranslationFile.cs | 2 +- .../Frontend.Translations.Tests/SpellCheck.cs | 4 +- 5 files changed, 33 insertions(+), 34 deletions(-) diff --git a/common/Tests/Frontend.Translations.Tests/LocalesTest.cs b/common/Tests/Frontend.Translations.Tests/LocalesTest.cs index 7f1788ca24..68c83ad70d 100644 --- a/common/Tests/Frontend.Translations.Tests/LocalesTest.cs +++ b/common/Tests/Frontend.Translations.Tests/LocalesTest.cs @@ -48,7 +48,7 @@ public class Tests { get { - return Path.GetFullPath("..\\..\\..\\..\\..\\..\\"); + return Path.GetFullPath("../../../../../../").Replace("\\", "/"); } } @@ -81,25 +81,24 @@ public class Tests var moduleWorkspaces = new List { - "packages\\client", - "packages\\common", - "packages\\components", - "packages\\editor", - "packages\\login" + "packages/client", + "packages/common", + "packages/components", + "packages/editor", + "packages/login" }; Workspaces = new List(); Workspaces.AddRange(moduleWorkspaces); - Workspaces.Add("public\\locales"); - + Workspaces.Add("public/locales"); var translationFiles = from wsPath in Workspaces let clientDir = Path.Combine(BasePath, wsPath) from filePath in Directory.EnumerateFiles(clientDir, "*.json", SearchOption.AllDirectories) - where filePath.Contains("public\\locales\\") - select Path.GetFullPath(filePath); + where filePath.Contains("public/locales/") + select Path.GetFullPath(filePath).Replace("\\", "/"); TranslationFiles = new List(); @@ -161,14 +160,14 @@ public class Tests var javascriptFiles = (from wsPath in Workspaces let clientDir = Path.Combine(BasePath, wsPath) from file in Directory.EnumerateFiles(clientDir, "*.js", SearchOption.AllDirectories) - where !file.Contains("dist\\") + where !file.Contains("dist/") && !file.Contains(".test.js") && !file.Contains(".stories.js") select file) .ToList(); javascriptFiles.AddRange(from wsPath in Workspaces let clientDir = Path.Combine(BasePath, wsPath) from file in Directory.EnumerateFiles(clientDir, "*.jsx", SearchOption.AllDirectories) - where !file.Contains("dist\\") + where !file.Contains("dist/") && !file.Contains(".test.jsx") && !file.Contains(".stories.jsx") select file); JavaScriptFiles = new List(); @@ -278,7 +277,7 @@ public class Tests } CommonTranslations = TranslationFiles - .Where(file => file.FilePath.StartsWith($"{BasePath}public\\locales")) + .Where(file => file.FilePath.StartsWith($"{BasePath}public/locales")) .Select(t => new LanguageItem { Path = t.FilePath, @@ -296,8 +295,8 @@ public class Tests public static Tuple getPaths(string language) { - const string dictionariesPath = @"..\..\..\dictionaries"; - const string additionalPath = @"..\..\..\additional"; + const string dictionariesPath = @"../../../dictionaries"; + const string additionalPath = @"../../../additional"; var path = dictionariesPath; @@ -505,7 +504,7 @@ public class Tests string currentDirectory = Path.GetDirectoryName(notExistJsonPath); - string fullPathOnly = Path.GetFullPath(currentDirectory); + string fullPathOnly = Path.GetFullPath(currentDirectory).Replace("\\", "/"); if (!Directory.Exists(fullPathOnly)) Directory.CreateDirectory(fullPathOnly); @@ -553,7 +552,7 @@ public class Tests var lngFilePaths = lng.Files.Select(f => f.FilePath).ToList(); var notFoundFilePaths = enFilePaths - .Select(p => p.Replace("\\en\\", $"\\{lng.Lng}\\")) + .Select(p => p.Replace("/en/", $"/{lng.Lng}/")) .Where(p => !lngFilePaths.Contains(p)); message += string.Join("\r\n", notFoundFilePaths); @@ -613,7 +612,7 @@ public class Tests { var lngKeys = lng.Translations.Select(f => f.Key).ToList(); - var enKeys = enLanguages.Where(l => l.Path == lng.Path.Replace($"\\{lng.Language}\\", "\\en\\")) + var enKeys = enLanguages.Where(l => l.Path == lng.Path.Replace($"/{lng.Language}/", "/en/")) .SelectMany(l => l.Translations.Select(f => f.Key)) .ToList(); @@ -698,7 +697,7 @@ public class Tests if (module.AppliedJsTranslationKeys == null && module.AvailableLanguages != null) { - message += $"{++index}. 'ANY LANGUAGES' '{module.Path}' NOT USES"; + message += $"{++index}. 'ANY LANGUAGES' '{module.Path}' NOT USED\r\n"; var list = module.AvailableLanguages .SelectMany(l => l.Translations.Select(t => t.Key).ToList()) @@ -1144,14 +1143,14 @@ public class Tests /// /// Converts a file from one encoding to another. /// - /// the file to convert - /// the destination for the converted file - /// the original file encoding - /// the encoding to which the contents should be converted + /// the file to convert + /// the destination for the converted file + /// the original file encoding + /// the encoding to which the contents should be converted //public static void ConvertFileEncoding(string sourcePath, string destPath, // Encoding sourceEncoding, Encoding destEncoding) //{ - // // If the destination’s parent doesn’t exist, create it. + // // If the destination�s parent doesn�t exist, create it. // var parent = Path.GetDirectoryName(Path.GetFullPath(destPath)); // if (!Directory.Exists(parent)) // { diff --git a/common/Tests/Frontend.Translations.Tests/Models/JavaScriptFile.cs b/common/Tests/Frontend.Translations.Tests/Models/JavaScriptFile.cs index cb18443aaa..a2160e7c88 100644 --- a/common/Tests/Frontend.Translations.Tests/Models/JavaScriptFile.cs +++ b/common/Tests/Frontend.Translations.Tests/Models/JavaScriptFile.cs @@ -32,7 +32,7 @@ public class JavaScriptFile { public JavaScriptFile(string path) { - Path = path.Replace("/", "\\"); + Path = path.Replace("\\", "/"); } public string Path { get; } diff --git a/common/Tests/Frontend.Translations.Tests/Models/SpellCheckResult.cs b/common/Tests/Frontend.Translations.Tests/Models/SpellCheckResult.cs index b75b35f83b..3e10b44567 100644 --- a/common/Tests/Frontend.Translations.Tests/Models/SpellCheckResult.cs +++ b/common/Tests/Frontend.Translations.Tests/Models/SpellCheckResult.cs @@ -35,17 +35,17 @@ namespace Frontend.Translations.Tests.Models; public class SpellCheckResult { - private static Regex wordRegex = new Regex(@"[\p{L}-]+", RegexOptions.Multiline | RegexOptions.Compiled); - private static Regex regVariables = new Regex("\\{\\{([^\\{].?[^\\}]+)\\}\\}", RegexOptions.Compiled | RegexOptions.Multiline); - private static Regex htmlTags = new Regex("<[^>]*>", RegexOptions.Compiled | RegexOptions.Multiline); - private static List trademarks = new List() + private static readonly Regex wordRegex = new Regex(@"[\p{L}-]+", RegexOptions.Multiline | RegexOptions.Compiled); + private static readonly Regex regVariables = new Regex("\\{\\{([^\\{].?[^\\}]+)\\}\\}", RegexOptions.Compiled | RegexOptions.Multiline); + private static readonly Regex htmlTags = new Regex("<[^>]*>", RegexOptions.Compiled | RegexOptions.Multiline); + private static readonly List trademarks = new List() { "onlyoffice.com", "onlyoffice.eu", "Office Open XML", "ONLYOFFICE Desktop Editors", "ONLYOFFICE Desktop", "ONLYOFFICE Documents", "Google Drive", "Twitter", "Facebook", "LinkedIn", "Google", "Yandex", "Yandex.Disk", "Dropbox","OneDrive","ONLYOFFICE", "DocuSign", "e-mail", "SharePoint", "Windows Phone", "Enterprise Edition", "AES-256" }; - private static List exclusions = new List() + private static readonly List exclusions = new List() { "ok","doc","docx","xls","xlsx","ppt","pptx","xml","ooxml","jpg","png","mb","ip", "canvas","tag","Disk","Box","Dcs","zip","Android","Authenticator","iOS","Windows", @@ -53,7 +53,7 @@ public class SpellCheckResult "Portal","Favicon","URL","QR", "email", "app", "api" }; - private static List excludes = File.Exists("../../../spellcheck-excludes.json") + private static readonly List excludes = File.Exists("../../../spellcheck-excludes.json") ? JsonConvert.DeserializeObject>(File.ReadAllText("../../../spellcheck-excludes.json")) : new List(); diff --git a/common/Tests/Frontend.Translations.Tests/Models/TranslationFile.cs b/common/Tests/Frontend.Translations.Tests/Models/TranslationFile.cs index 53688a02a6..2ecd7976ab 100644 --- a/common/Tests/Frontend.Translations.Tests/Models/TranslationFile.cs +++ b/common/Tests/Frontend.Translations.Tests/Models/TranslationFile.cs @@ -33,7 +33,7 @@ public class TranslationFile { public TranslationFile(string path, List translations, string md5hash = null) { - FilePath = path.Replace("/", "\\"); + FilePath = path.Replace("\\", "/"); FileName = Path.GetFileName(FilePath); diff --git a/common/Tests/Frontend.Translations.Tests/SpellCheck.cs b/common/Tests/Frontend.Translations.Tests/SpellCheck.cs index 31ccf4c4de..595e1f2655 100644 --- a/common/Tests/Frontend.Translations.Tests/SpellCheck.cs +++ b/common/Tests/Frontend.Translations.Tests/SpellCheck.cs @@ -56,8 +56,8 @@ public static class SpellCheck public static DicPaths GetDictionaryPaths(string lng) { - const string dictionariesPath = @"..\..\..\dictionaries"; - const string additionalPath = @"..\..\..\additional"; + const string dictionariesPath = @"../../../dictionaries"; + const string additionalPath = @"../../../additional"; var path = dictionariesPath; string language; From 3ae92932a29cb9368e9b9bff7f80497017cc6f89 Mon Sep 17 00:00:00 2001 From: Alexey Safronov Date: Fri, 21 Oct 2022 17:30:07 +0300 Subject: [PATCH 3/8] Removed invalid chars --- .../Tests/Frontend.Translations.Tests/LocalesTest.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/Tests/Frontend.Translations.Tests/LocalesTest.cs b/common/Tests/Frontend.Translations.Tests/LocalesTest.cs index 68c83ad70d..3494d6f852 100644 --- a/common/Tests/Frontend.Translations.Tests/LocalesTest.cs +++ b/common/Tests/Frontend.Translations.Tests/LocalesTest.cs @@ -1143,14 +1143,14 @@ public class Tests /// /// Converts a file from one encoding to another. /// - /// the file to convert - /// the destination for the converted file - /// the original file encoding - /// the encoding to which the contents should be converted + /// the file to convert + /// the destination for the converted file + /// the original file encoding + /// the encoding to which the contents should be converted //public static void ConvertFileEncoding(string sourcePath, string destPath, // Encoding sourceEncoding, Encoding destEncoding) //{ - // // If the destination�s parent doesn�t exist, create it. + // // If the destination's parent doesn't exist, create it. // var parent = Path.GetDirectoryName(Path.GetFullPath(destPath)); // if (!Directory.Exists(parent)) // { From 31c90ae95ad0930b445769fbf44688b6caa167ad Mon Sep 17 00:00:00 2001 From: Alexey Safronov Date: Fri, 21 Oct 2022 18:31:31 +0300 Subject: [PATCH 4/8] Added more logs --- .../LocalesTest.cs | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/common/Tests/Frontend.Translations.Tests/LocalesTest.cs b/common/Tests/Frontend.Translations.Tests/LocalesTest.cs index 3494d6f852..ee7dd5ff0d 100644 --- a/common/Tests/Frontend.Translations.Tests/LocalesTest.cs +++ b/common/Tests/Frontend.Translations.Tests/LocalesTest.cs @@ -100,6 +100,9 @@ public class Tests where filePath.Contains("public/locales/") select Path.GetFullPath(filePath).Replace("\\", "/"); + TestContext.Progress.WriteLine($"Base path = {BasePath}"); + TestContext.Progress.WriteLine($"Found translationFiles by *.json filter = {translationFiles.Count()}. First path is '{translationFiles.FirstOrDefault()}'"); + TranslationFiles = new List(); foreach (var path in translationFiles) @@ -153,22 +156,26 @@ public class Tests catch (Exception ex) { ParseJsonErrors.Add(new ParseJsonError(path, ex)); - Debug.WriteLine($"File path = {path} failed to parse with error: {ex.Message}"); + TestContext.Progress.WriteLine($"File path = {path} failed to parse with error: {ex.Message}"); } } + TestContext.Progress.WriteLine($"Found TranslationFiles = {TranslationFiles.Count()}. First path is '{TranslationFiles.FirstOrDefault()?.FilePath}'"); + var javascriptFiles = (from wsPath in Workspaces let clientDir = Path.Combine(BasePath, wsPath) - from file in Directory.EnumerateFiles(clientDir, "*.js", SearchOption.AllDirectories) - where !file.Contains("dist/") && !file.Contains(".test.js") && !file.Contains(".stories.js") - select file) + from filePath in Directory.EnumerateFiles(clientDir, "*.js", SearchOption.AllDirectories) + where !filePath.Contains("dist/") && !filePath.Contains(".test.js") && !filePath.Contains(".stories.js") + select filePath.Replace("\\", "/")) .ToList(); javascriptFiles.AddRange(from wsPath in Workspaces let clientDir = Path.Combine(BasePath, wsPath) - from file in Directory.EnumerateFiles(clientDir, "*.jsx", SearchOption.AllDirectories) - where !file.Contains("dist/") && !file.Contains(".test.jsx") && !file.Contains(".stories.jsx") - select file); + from filePath in Directory.EnumerateFiles(clientDir, "*.jsx", SearchOption.AllDirectories) + where !filePath.Contains("dist/") && !filePath.Contains(".test.jsx") && !filePath.Contains(".stories.jsx") + select filePath.Replace("\\", "/")); + + TestContext.Progress.WriteLine($"Found javascriptFiles by *.js(x) filter = {javascriptFiles.Count()}. First path is '{javascriptFiles.FirstOrDefault()}'"); JavaScriptFiles = new List(); @@ -221,6 +228,8 @@ public class Tests JavaScriptFiles.Add(jsFile); } + TestContext.Progress.WriteLine($"Found JavaScriptFiles = {JavaScriptFiles.Count()}. First path is '{JavaScriptFiles.FirstOrDefault()?.Path}'"); + ModuleFolders = new List(); var list = TranslationFiles @@ -245,6 +254,8 @@ public class Tests }) .ToList(); + TestContext.Progress.WriteLine($"Found moduleTranslations = {moduleTranslations.Count()}. First path is '{moduleTranslations.FirstOrDefault()?.ModulePath}'"); + var moduleJsTranslatedFiles = JavaScriptFiles .Select(t => new { @@ -260,6 +271,8 @@ public class Tests }) .ToList(); + TestContext.Progress.WriteLine($"Found moduleJsTranslatedFiles = {moduleJsTranslatedFiles.Count()}. First path is '{moduleJsTranslatedFiles.FirstOrDefault()?.ModulePath}'"); + foreach (var wsPath in moduleWorkspaces) { var t = moduleTranslations.FirstOrDefault(t => t.ModulePath == wsPath); @@ -276,6 +289,8 @@ public class Tests }); } + TestContext.Progress.WriteLine($"Found ModuleFolders = {ModuleFolders.Count()}. First path is '{ModuleFolders.FirstOrDefault()?.Path}'"); + CommonTranslations = TranslationFiles .Where(file => file.FilePath.StartsWith($"{BasePath}public/locales")) .Select(t => new LanguageItem @@ -284,6 +299,8 @@ public class Tests Language = t.Language, Translations = t.Translations }).ToList(); + + TestContext.Progress.WriteLine($"Found CommonTranslations = {CommonTranslations.Count()}. First path is '{CommonTranslations.FirstOrDefault()?.Path}'"); } [Test] From 34490919b179a531e91689ac142c1c45307b0653 Mon Sep 17 00:00:00 2001 From: Alexey Safronov Date: Fri, 21 Oct 2022 19:07:07 +0300 Subject: [PATCH 5/8] Added Utils.ConvertPathToOS method --- .../LocalesTest.cs | 62 +++++++++---------- .../Models/JavaScriptFile.cs | 2 +- .../Models/TranslationFile.cs | 2 +- .../Frontend.Translations.Tests/Utils.cs | 14 +++++ 4 files changed, 47 insertions(+), 33 deletions(-) create mode 100644 common/Tests/Frontend.Translations.Tests/Utils.cs diff --git a/common/Tests/Frontend.Translations.Tests/LocalesTest.cs b/common/Tests/Frontend.Translations.Tests/LocalesTest.cs index ee7dd5ff0d..8e966b391b 100644 --- a/common/Tests/Frontend.Translations.Tests/LocalesTest.cs +++ b/common/Tests/Frontend.Translations.Tests/LocalesTest.cs @@ -48,7 +48,7 @@ public class Tests { get { - return Path.GetFullPath("../../../../../../").Replace("\\", "/"); + return Path.GetFullPath(Utils.ConvertPathToOS("../../../../../../")); } } @@ -58,10 +58,12 @@ public class Tests public List ModuleFolders { get; set; } public List> NotTranslatedToasts { get; set; } public List CommonTranslations { get; set; } - public List ParseJsonErrors { get; set; } - //public List WrongEncodingJsonErrors { get; set; } - - private static readonly string _md5ExcludesPath = "../../../md5-excludes.json"; + public List ParseJsonErrors { get; set; } + public static string ConvertPathToOS { get; private set; } + + //public List WrongEncodingJsonErrors { get; set; } + + private static readonly string _md5ExcludesPath = Utils.ConvertPathToOS("../../../md5-excludes.json"); //private static string _encodingExcludesPath = "../../../encoding-excludes.json"; @@ -81,24 +83,24 @@ public class Tests var moduleWorkspaces = new List { - "packages/client", - "packages/common", - "packages/components", - "packages/editor", - "packages/login" + Utils.ConvertPathToOS("packages/client"), + Utils.ConvertPathToOS("packages/common"), + Utils.ConvertPathToOS("packages/components"), + Utils.ConvertPathToOS("packages/editor"), + Utils.ConvertPathToOS("packages/login") }; Workspaces = new List(); Workspaces.AddRange(moduleWorkspaces); - Workspaces.Add("public/locales"); + Workspaces.Add(Utils.ConvertPathToOS("public/locales")); var translationFiles = from wsPath in Workspaces let clientDir = Path.Combine(BasePath, wsPath) from filePath in Directory.EnumerateFiles(clientDir, "*.json", SearchOption.AllDirectories) - where filePath.Contains("public/locales/") - select Path.GetFullPath(filePath).Replace("\\", "/"); + where filePath.Contains(Utils.ConvertPathToOS("public/locales/")) + select Path.GetFullPath(filePath); TestContext.Progress.WriteLine($"Base path = {BasePath}"); TestContext.Progress.WriteLine($"Found translationFiles by *.json filter = {translationFiles.Count()}. First path is '{translationFiles.FirstOrDefault()}'"); @@ -165,15 +167,15 @@ public class Tests var javascriptFiles = (from wsPath in Workspaces let clientDir = Path.Combine(BasePath, wsPath) from filePath in Directory.EnumerateFiles(clientDir, "*.js", SearchOption.AllDirectories) - where !filePath.Contains("dist/") && !filePath.Contains(".test.js") && !filePath.Contains(".stories.js") - select filePath.Replace("\\", "/")) + where !filePath.Contains(Utils.ConvertPathToOS("dist/")) && !filePath.Contains(".test.js") && !filePath.Contains(".stories.js") + select Utils.ConvertPathToOS(filePath)) .ToList(); javascriptFiles.AddRange(from wsPath in Workspaces let clientDir = Path.Combine(BasePath, wsPath) from filePath in Directory.EnumerateFiles(clientDir, "*.jsx", SearchOption.AllDirectories) - where !filePath.Contains("dist/") && !filePath.Contains(".test.jsx") && !filePath.Contains(".stories.jsx") - select filePath.Replace("\\", "/")); + where !filePath.Contains(Utils.ConvertPathToOS("dist/")) && !filePath.Contains(".test.jsx") && !filePath.Contains(".stories.jsx") + select Utils.ConvertPathToOS(filePath)); TestContext.Progress.WriteLine($"Found javascriptFiles by *.js(x) filter = {javascriptFiles.Count()}. First path is '{javascriptFiles.FirstOrDefault()}'"); @@ -292,7 +294,7 @@ public class Tests TestContext.Progress.WriteLine($"Found ModuleFolders = {ModuleFolders.Count()}. First path is '{ModuleFolders.FirstOrDefault()?.Path}'"); CommonTranslations = TranslationFiles - .Where(file => file.FilePath.StartsWith($"{BasePath}public/locales")) + .Where(file => file.FilePath.StartsWith(Utils.ConvertPathToOS($"{BasePath}public/locales"))) .Select(t => new LanguageItem { Path = t.FilePath, @@ -326,8 +328,8 @@ public class Tests break; } - var dicPath = Path.Combine(path, language, $"{language}.dic"); - var affPath = Path.Combine(path, language, $"{language}.aff"); + var dicPath = Utils.ConvertPathToOS(Path.Combine(path, language, $"{language}.dic")); + var affPath = Utils.ConvertPathToOS(Path.Combine(path, language, $"{language}.aff")); return new Tuple(dicPath, affPath); } @@ -521,7 +523,7 @@ public class Tests string currentDirectory = Path.GetDirectoryName(notExistJsonPath); - string fullPathOnly = Path.GetFullPath(currentDirectory).Replace("\\", "/"); + string fullPathOnly = Path.GetFullPath(currentDirectory); if (!Directory.Exists(fullPathOnly)) Directory.CreateDirectory(fullPathOnly); @@ -569,7 +571,7 @@ public class Tests var lngFilePaths = lng.Files.Select(f => f.FilePath).ToList(); var notFoundFilePaths = enFilePaths - .Select(p => p.Replace("/en/", $"/{lng.Lng}/")) + .Select(p => p.Replace(Utils.ConvertPathToOS("/en/"), Utils.ConvertPathToOS($"/{lng.Lng}/"))) .Where(p => !lngFilePaths.Contains(p)); message += string.Join("\r\n", notFoundFilePaths); @@ -578,7 +580,7 @@ public class Tests /*foreach (var path in notFoundFilePaths) { - SaveNotFoundLanguage(path.Replace($"\\{lng.Lng}\\", "\\en\\"), path); + SaveNotFoundLanguage(path.Replace(Utils.ConvertPathToOS($"\\{lng.Lng}\\"), Utils.ConvertPathToOS("\\en\\")), path); }*/ } } @@ -629,7 +631,7 @@ public class Tests { var lngKeys = lng.Translations.Select(f => f.Key).ToList(); - var enKeys = enLanguages.Where(l => l.Path == lng.Path.Replace($"/{lng.Language}/", "/en/")) + var enKeys = enLanguages.Where(l => l.Path == lng.Path.Replace(Utils.ConvertPathToOS($"/{lng.Language}/"), Utils.ConvertPathToOS("/en/"))) .SelectMany(l => l.Translations.Select(f => f.Key)) .ToList(); @@ -873,15 +875,13 @@ public class Tests switch (folderName) { case "Client": - return Workspaces.Find(w => w.Contains("ASC.Web.Client")); - case "Files": - return Workspaces.Find(w => w.Contains("ASC.Files")); + return Workspaces.Find(w => w.Contains("client")); + case "Editor": + return Workspaces.Find(w => w.Contains("editor")); case "Login": - return Workspaces.Find(w => w.Contains("ASC.Web.Login")); - case "People": - return Workspaces.Find(w => w.Contains("ASC.People")); + return Workspaces.Find(w => w.Contains("login")); default: - return Path.Combine(BasePath, "public\\locales"); + return Path.Combine(BasePath, Utils.ConvertPathToOS("public\\locales")); } } diff --git a/common/Tests/Frontend.Translations.Tests/Models/JavaScriptFile.cs b/common/Tests/Frontend.Translations.Tests/Models/JavaScriptFile.cs index a2160e7c88..b68eb6aea9 100644 --- a/common/Tests/Frontend.Translations.Tests/Models/JavaScriptFile.cs +++ b/common/Tests/Frontend.Translations.Tests/Models/JavaScriptFile.cs @@ -32,7 +32,7 @@ public class JavaScriptFile { public JavaScriptFile(string path) { - Path = path.Replace("\\", "/"); + Path = Utils.ConvertPathToOS(path); } public string Path { get; } diff --git a/common/Tests/Frontend.Translations.Tests/Models/TranslationFile.cs b/common/Tests/Frontend.Translations.Tests/Models/TranslationFile.cs index 2ecd7976ab..598c6f18f9 100644 --- a/common/Tests/Frontend.Translations.Tests/Models/TranslationFile.cs +++ b/common/Tests/Frontend.Translations.Tests/Models/TranslationFile.cs @@ -33,7 +33,7 @@ public class TranslationFile { public TranslationFile(string path, List translations, string md5hash = null) { - FilePath = path.Replace("\\", "/"); + FilePath = Utils.ConvertPathToOS(path); FileName = Path.GetFileName(FilePath); diff --git a/common/Tests/Frontend.Translations.Tests/Utils.cs b/common/Tests/Frontend.Translations.Tests/Utils.cs new file mode 100644 index 0000000000..6f8f432fd9 --- /dev/null +++ b/common/Tests/Frontend.Translations.Tests/Utils.cs @@ -0,0 +1,14 @@ +using System; +using System.IO; + +namespace Frontend.Translations.Tests +{ + public static class Utils + { + public static string ConvertPathToOS(string path) + { + return Path.DirectorySeparatorChar == '/' ? path.Replace("\\", "/") : path.Replace("/", "\\"); + } + } +} + From d316a68b5172aa0ed4e498f7b336c8e522693d79 Mon Sep 17 00:00:00 2001 From: Alexey Safronov Date: Fri, 21 Oct 2022 19:23:58 +0300 Subject: [PATCH 6/8] Fix _md5ExcludesPath --- common/Tests/Frontend.Translations.Tests/LocalesTest.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/Tests/Frontend.Translations.Tests/LocalesTest.cs b/common/Tests/Frontend.Translations.Tests/LocalesTest.cs index 8e966b391b..b878e5103c 100644 --- a/common/Tests/Frontend.Translations.Tests/LocalesTest.cs +++ b/common/Tests/Frontend.Translations.Tests/LocalesTest.cs @@ -63,7 +63,7 @@ public class Tests //public List WrongEncodingJsonErrors { get; set; } - private static readonly string _md5ExcludesPath = Utils.ConvertPathToOS("../../../md5-excludes.json"); + private static readonly string _md5ExcludesPath = Path.GetFullPath(Utils.ConvertPathToOS("../../../md5-excludes.json")); //private static string _encodingExcludesPath = "../../../encoding-excludes.json"; @@ -303,6 +303,9 @@ public class Tests }).ToList(); TestContext.Progress.WriteLine($"Found CommonTranslations = {CommonTranslations.Count()}. First path is '{CommonTranslations.FirstOrDefault()?.Path}'"); + + TestContext.Progress.WriteLine($"Found _md5Excludes = {_md5Excludes.Count()} Path to file '{_md5ExcludesPath}'"); + } [Test] From bc12140f9ea67c0988d2fb66b2a8e4b9b0ad128c Mon Sep 17 00:00:00 2001 From: Alexey Safronov Date: Mon, 24 Oct 2022 11:01:11 +0300 Subject: [PATCH 7/8] Skip pt-BR from DublicatesFilesByMD5HashTest --- common/Tests/Frontend.Translations.Tests/LocalesTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/common/Tests/Frontend.Translations.Tests/LocalesTest.cs b/common/Tests/Frontend.Translations.Tests/LocalesTest.cs index b878e5103c..17e3fd5fb8 100644 --- a/common/Tests/Frontend.Translations.Tests/LocalesTest.cs +++ b/common/Tests/Frontend.Translations.Tests/LocalesTest.cs @@ -428,6 +428,7 @@ public class Tests public void DublicatesFilesByMD5HashTest() { var duplicatesByMD5 = TranslationFiles + .Where(t => t.Language != "pt-BR") .Where(t => !_md5Excludes.Contains(t.Md5Hash)) .GroupBy(t => t.Md5Hash) .Where(grp => grp.Count() > 1) From 440943f81b2a6992aa9a954d77bcdec844fd039f Mon Sep 17 00:00:00 2001 From: Alexey Safronov Date: Mon, 24 Oct 2022 13:31:11 +0300 Subject: [PATCH 8/8] Update run.translations.tests.sh --- build/run.translations.tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/run.translations.tests.sh b/build/run.translations.tests.sh index 8545a6540c..14b5896410 100755 --- a/build/run.translations.tests.sh +++ b/build/run.translations.tests.sh @@ -5,4 +5,4 @@ dir=$(builtin cd $rd/../; pwd) echo "Root directory:" $dir -dotnet test $dir/common/Tests/Frontend.Translations.Tests/Frontend.Translations.Tests.csproj --filter "TestCategory=FastRunning" -l:html -r TestsResults \ No newline at end of file +dotnet test $dir/common/Tests/Frontend.Translations.Tests/Frontend.Translations.Tests.csproj --filter "TestCategory=FastRunning" -l:html -r $dir/TestsResults \ No newline at end of file