pascalabcnet/bin/TestRunner.pas

565 lines
20 KiB
ObjectPascal
Raw Permalink Normal View History

// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
2015-06-12 21:59:28 +03:00
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
2015-05-14 22:35:07 +03:00
{$reference Compiler.dll}
{$reference CodeCompletion.dll}
{$reference Errors.dll}
{$reference CompilerTools.dll}
2016-05-06 14:56:19 +03:00
{$reference Localization.dll}
2015-05-14 22:35:07 +03:00
{$reference System.Windows.Forms.dll}
New languages engine (#3120) * Implement first version of languages interfaces and classes ParsersController заменен на LanguageProvider. * Update ParserTools.csproj * Update RemoteCompiler.cs * Update TestRunner * Rename LanguageIntegrator project to Languages * Update TestRunner * Rename Parsers folder * Rename PascalABCParser.dll to PascalABCLanguage.dll * Reorganise LanguageIntegrator and rename DocTagsParser * Update Release Generators * Update language loading messages * Update linux version * Move BaseParser fields to ILanguage interface * Revert "Update Release Generators" This reverts commit 26a991c71b81e643d9fbd9a815ddca222768dda9. * Revert "Rename PascalABCParser.dll to PascalABCLanguage.dll" * Clean the mess in parser folders * Organize namespaces properly * Revert "Rename LanguageIntegrator project to Languages" * Add new enclosing folders for standard languages * Organize namespaces of LanguageIntegrator properly * Rename StandardLanguages to Languages * Comment the rest of Visual basic source code * Update OutputPath in pascal parser project * Move BaseParser methods to IParser * Restore Pascal parser project initial structure * Add PascalLanguage project * Move SyntaxTreeConverters project to Languages\Pascal folder * Rename SemanticRules in parser project * Rename Errors1 to Errors in parser project * Delete LambdaConverter dll from installer * Update language integrator to load *Language.dll files * Move lambda converter project to pascal lanuage dir * Revert "Delete LambdaConverter dll from installer" This reverts commit dd56f559ebe4f8c4c5c33752d44e6953001b96a5. * Switch off VBNETParser building * Delete syntax tree converters controller * Delete lambda converter dll from repository * Reorganize syntax tree to semantic tree conversion stage * Add BaseLanguage class to make language initialization more neat * Delete syntax tree post processors entity from ILanguage and refactor ABCStatistics calls * Add new IDocParser interface for documentation comments parser * Clean up folders * Add helper data structures to reduce parameters amount in CompileInterface and CompileImplementation * Add documentation to language classes * Move Union struct in global namespace and project (ParserTools) * Add more comments and a safe select language method * Rename SemanticRules class * Fix directives format null bug * Add System.Linq ref to LanguageIntegrator * Delete SyntaxToSemanticTreeConverter interface * Add BaseSyntaxTreeConverter * Call safe select language method in intellisence * Delete source files providers from parsers * Rename GetSyntaxTree method * Change Prebuild tree to be virtual - not abstract * Refresh documentation a bit * Add temporary language check for ABCHealth button * Add parser reference to parser tools * Move current compilation unit assigning higher to avoid bug with unit check * Delete null DirectiveInfo's and refactor directives' code * Add a few more comments
2024-05-25 12:26:32 +03:00
{$reference LanguageIntegrator.dll}
2015-05-14 22:35:07 +03:00
uses PascalABCCompiler, System.IO, System.Diagnostics;
type
LanguageTestsInfo = auto class
languageName: string;
languageExtensions: array of string;
commentSymbol: string;
end;
2018-06-03 20:49:55 +03:00
var
TestSuiteDir: string;
CurrentLanguageInfo: LanguageTestsInfo;
2021-01-05 14:32:21 +03:00
nogui: boolean;
2018-06-03 20:49:55 +03:00
var
PathSeparator: string := Path.DirectorySeparatorChar;
2015-05-14 22:35:07 +03:00
function IsUnix: boolean;
begin
Result := (System.Environment.OSVersion.Platform = System.PlatformID.Unix) or (System.Environment.OSVersion.Platform = System.PlatformID.MacOSX);
end;
function GetCurrentLanguageInfo(dir: string): LanguageTestsInfo;
2015-05-14 22:35:07 +03:00
begin
var configDict := &File.ReadLines(dir + PathSeparator + 'testsettings.config')
.Select(line -> line.Split([':', ' '], System.StringSplitOptions.RemoveEmptyEntries))
.ToDictionary(arr -> arr[0], arr -> arr[1]);
var languageInformation := Languages.Facade.LanguageProvider.Instance.SelectLanguageByName(configDict['languageName']).LanguageInformation;
Result := new LanguageTestsInfo(languageInformation.Name, languageInformation.FilesExtensions, languageInformation.CommentSymbol);
2015-05-14 22:35:07 +03:00
end;
function GetFilesByExtensions(path: string; extensions: array of string; searchOption: SearchOption := System.IO.SearchOption.TopDirectoryOnly): array of string;
begin
Result := extensions.SelectMany(ext -> Directory.GetFiles(path, $'*{ext}', searchOption)).ToArray();
end;
function GetCodeExamplesDir: string;
begin
var dir := Path.GetDirectoryName(GetEXEFileName());
Result := (new DirectoryInfo(dir)).Parent.FullName + PathSeparator + 'CodeExamples' + PathSeparator + CurrentLanguageInfo.languageName;
end;
2015-05-14 22:35:07 +03:00
procedure CompileErrorTests(withide: boolean);
begin
var dir := TestSuiteDir + PathSeparator + 'errors';
if not Directory.Exists(dir) then exit;
2021-10-31 15:48:32 +03:00
var commentSymbol := CurrentLanguageInfo.commentSymbol;
var files := GetFilesByExtensions(dir, CurrentLanguageInfo.languageExtensions);
2015-05-14 22:35:07 +03:00
for var i := 0 to files.Length - 1 do
begin
2021-10-31 15:48:32 +03:00
var comp := new Compiler();
var content := &File.ReadAllText(files[i]);
if content.StartsWith(commentSymbol + 'winonly') and IsUnix then
continue;
if content.StartsWith(commentSymbol + 'exclude') then
2021-10-17 13:04:24 +03:00
continue;
var errorMessage := '';
if content.StartsWith(commentSymbol + '!') then
2021-10-17 13:04:24 +03:00
begin
errorMessage := content.Substring(commentSymbol.Length + 1, content.IndexOf(System.Environment.NewLine) - commentSymbol.Length + 1).Trim;
2021-10-17 13:04:24 +03:00
end;
2018-06-03 20:49:55 +03:00
var co: CompilerOptions := new CompilerOptions(files[i], CompilerOptions.OutputType.ConsoleApplicaton);
2015-05-14 22:35:07 +03:00
co.Debug := true;
2018-06-03 20:49:55 +03:00
co.OutputDirectory := TestSuiteDir + PathSeparator + 'errors';
2015-05-14 22:35:07 +03:00
co.UseDllForSystemUnits := false;
co.RunWithEnvironment := withide;
comp.ErrorsList.Clear();
comp.Warnings.Clear();
comp.Compile(co);
if comp.ErrorsList.Count = 0 then
begin
2021-01-05 14:32:21 +03:00
if nogui then
raise new Exception('Compilation of error sample ' + files[i] + ' was successfull');
2018-06-03 20:49:55 +03:00
System.Windows.Forms.MessageBox.Show('Compilation of error sample ' + files[i] + ' was successfull' + System.Environment.NewLine);
2016-05-15 22:01:40 +03:00
Halt();
2015-05-14 22:35:07 +03:00
end
else if comp.ErrorsList.Count = 1 then
begin
if comp.ErrorsList[0].GetType() = typeof(PascalABCCompiler.Errors.CompilerInternalError) then
2021-01-05 14:32:21 +03:00
begin
if nogui then
raise new Exception('Compilation of ' + files[i] + ' failed' + System.Environment.NewLine + comp.ErrorsList[0].ToString());
2018-06-03 20:49:55 +03:00
System.Windows.Forms.MessageBox.Show('Compilation of ' + files[i] + ' failed' + System.Environment.NewLine + comp.ErrorsList[0].ToString());
2021-01-05 14:32:21 +03:00
end;
if (errorMessage <> '') and (comp.ErrorsList[comp.ErrorsList.Count - 1].Message.Trim <> errorMessage) then
2021-10-17 13:04:24 +03:00
begin
2021-10-31 15:48:32 +03:00
if nogui then
raise new Exception('Wrong error message in file ' + files[i] + ', should ' + errorMessage + ', is ' + comp.ErrorsList[comp.ErrorsList.Count - 1].Message);
System.Windows.Forms.MessageBox.Show('Wrong error message in file ' + files[i] + ', should ' + errorMessage + ', is ' + comp.ErrorsList[comp.ErrorsList.Count - 1].Message);
2021-10-17 13:04:24 +03:00
end;
2015-05-14 22:35:07 +03:00
end;
if i mod 50 = 0 then
2018-01-30 22:39:20 +03:00
System.GC.Collect();
2015-05-14 22:35:07 +03:00
end;
end;
procedure CompileAllRunTests(withdll: boolean; only32bit: boolean := false);
begin
var comp := new Compiler();
var commentSymbol := CurrentLanguageInfo.commentSymbol;
var files := GetFilesByExtensions(TestSuiteDir, CurrentLanguageInfo.languageExtensions);
2015-05-14 22:35:07 +03:00
for var i := 0 to files.Length - 1 do
begin
2021-04-18 18:40:56 +03:00
if IsUnix then
Println('Compile file ' + files[i]);
var content := &File.ReadAllText(files[i]);
if content.StartsWith(commentSymbol + 'winonly') and IsUnix then
continue;
if content.StartsWith(commentSymbol + 'nopabcrtl') and withdll then
2019-06-30 15:22:24 +03:00
continue;
2018-06-03 20:49:55 +03:00
var co: CompilerOptions := new CompilerOptions(files[i], CompilerOptions.OutputType.ConsoleApplicaton);
2015-05-14 22:35:07 +03:00
co.Debug := true;
2018-06-03 20:49:55 +03:00
co.OutputDirectory := TestSuiteDir + PathSeparator + 'exe';
2023-08-14 00:17:35 +03:00
Directory.CreateDirectory(co.OutputDirectory);
2015-05-14 22:35:07 +03:00
co.UseDllForSystemUnits := withdll;
co.RunWithEnvironment := false;
co.IgnoreRtlErrors := false;
co.Only32Bit := only32bit;
comp.ErrorsList.Clear();
comp.Warnings.Clear();
comp.Compile(co);
if comp.ErrorsList.Count > 0 then
begin
2021-01-05 14:32:21 +03:00
if nogui then
raise new Exception('Compilation of ' + files[i] + ' failed' + System.Environment.NewLine + comp.ErrorsList[0].ToString());
2018-06-03 20:49:55 +03:00
System.Windows.Forms.MessageBox.Show('Compilation of ' + files[i] + ' failed' + System.Environment.NewLine + comp.ErrorsList[0].ToString());
2018-05-13 15:19:54 +03:00
Halt();
2015-05-14 22:35:07 +03:00
end;
if content.StartsWith(commentSymbol + '!') then
2024-01-04 17:32:19 +03:00
begin
var warning := content.Substring(commentSymbol.Length + 1, content.IndexOf(System.Environment.NewLine) - commentSymbol.Length + 1).Trim;
2024-01-04 17:32:19 +03:00
if comp.Warnings.Count = 0 then
begin
if nogui then
raise new Exception('Missing warning in ' + files[i]);
System.Windows.Forms.MessageBox.Show('Missing warning in ' + files[i]);
2024-01-04 17:32:19 +03:00
Halt();
end;
if comp.Warnings[0].Message <> warning then
begin
if nogui then
raise new Exception('Wrong warning for ' + files[i] + ': ' + comp.Warnings[0].Message);
System.Windows.Forms.MessageBox.Show('Wrong warning for ' + files[i] + ': ' + comp.Warnings[0].Message);
2024-01-04 17:32:19 +03:00
Halt();
end;
end;
if i mod 50 = 0 then
begin
2018-01-30 22:39:20 +03:00
System.GC.Collect();
end;
2015-05-14 22:35:07 +03:00
end;
2018-05-20 15:18:29 +03:00
//Println;
2015-05-14 22:35:07 +03:00
end;
procedure CompileAllCompilationTests(dir: string; withdll: boolean);
begin
var comp := new Compiler();
var fullDirName := TestSuiteDir + PathSeparator + dir;
if not Directory.Exists(fullDirName) then exit;
var commentSymbol := CurrentLanguageInfo.commentSymbol;
var files := GetFilesByExtensions(fullDirName, CurrentLanguageInfo.languageExtensions);
2015-05-14 22:35:07 +03:00
for var i := 0 to files.Length - 1 do
begin
var content := &File.ReadAllText(files[i]);
if content.StartsWith(commentSymbol + 'winonly') and IsUnix then
continue;
2018-06-03 20:49:55 +03:00
var co: CompilerOptions := new CompilerOptions(files[i], CompilerOptions.OutputType.ConsoleApplicaton);
2015-05-14 22:35:07 +03:00
co.Debug := true;
2018-06-03 20:49:55 +03:00
co.OutputDirectory := TestSuiteDir + PathSeparator + dir;
2015-05-14 22:35:07 +03:00
co.UseDllForSystemUnits := withdll;
co.RunWithEnvironment := false;
co.IgnoreRtlErrors := false;
comp.ErrorsList.Clear();
comp.Warnings.Clear();
comp.Compile(co);
if comp.ErrorsList.Count > 0 then
begin
2021-01-05 14:32:21 +03:00
if nogui then
raise new Exception('Compilation of ' + files[i] + ' failed' + System.Environment.NewLine + comp.ErrorsList[0].ToString());
2018-06-03 20:49:55 +03:00
System.Windows.Forms.MessageBox.Show('Compilation of ' + files[i] + ' failed' + System.Environment.NewLine + comp.ErrorsList[0].ToString());
2015-05-14 22:35:07 +03:00
Halt();
end;
if i mod 50 = 0 then
2018-01-30 22:39:20 +03:00
System.GC.Collect();
2015-05-14 22:35:07 +03:00
end;
end;
procedure CompileAllUnits;
begin
var comp := new Compiler();
// Не пропускать ошибки сохранения PCU, в тесте создания PCU
comp.InternalDebug.SkipPCUErrors := false;
2018-06-03 20:49:55 +03:00
var dir := TestSuiteDir + PathSeparator + 'units' + PathSeparator;
if not Directory.Exists(dir) then exit;
var commentSymbol := CurrentLanguageInfo.commentSymbol;
var files := GetFilesByExtensions(TestSuiteDir + PathSeparator + 'units', CurrentLanguageInfo.languageExtensions);
2015-05-14 22:35:07 +03:00
for var i := 0 to files.Length - 1 do
begin
var content := &File.ReadAllText(files[i]);
if content.StartsWith(commentSymbol + 'winonly') and IsUnix then
continue;
2018-06-03 20:49:55 +03:00
var co: CompilerOptions := new CompilerOptions(files[i], CompilerOptions.OutputType.ConsoleApplicaton);
2015-05-14 22:35:07 +03:00
co.Debug := true;
co.OutputDirectory := dir;
co.UseDllForSystemUnits := false;
comp.ErrorsList.Clear();
comp.Warnings.Clear();
comp.Compile(co);
if comp.ErrorsList.Count > 0 then
begin
2021-01-05 14:32:21 +03:00
if nogui then
raise new Exception('Compilation of ' + files[i] + ' failed' + System.Environment.NewLine + comp.ErrorsList[0].ToString());
2018-06-03 20:49:55 +03:00
System.Windows.Forms.MessageBox.Show('Compilation of ' + files[i] + ' failed' + System.Environment.NewLine + comp.ErrorsList[0].ToString());
2015-05-14 22:35:07 +03:00
Halt();
end;
end;
2018-01-30 22:39:20 +03:00
System.GC.Collect;
2015-05-14 22:35:07 +03:00
end;
procedure CompileAllUsesUnits;
begin
var comp := new Compiler();
var dir := TestSuiteDir + PathSeparator + 'usesunits';
if not Directory.Exists(dir) then exit;
var commentSymbol := CurrentLanguageInfo.commentSymbol;
var files := GetFilesByExtensions(dir, CurrentLanguageInfo.languageExtensions);
2015-05-14 22:35:07 +03:00
for var i := 0 to files.Length - 1 do
begin
var content := &File.ReadAllText(files[i]);
if content.StartsWith(commentSymbol + 'winonly') and IsUnix then
continue;
2018-06-03 20:49:55 +03:00
var co: CompilerOptions := new CompilerOptions(files[i], CompilerOptions.OutputType.ConsoleApplicaton);
2015-05-14 22:35:07 +03:00
co.Debug := true;
2018-06-03 20:49:55 +03:00
co.OutputDirectory := TestSuiteDir + PathSeparator + 'exe';
2015-05-14 22:35:07 +03:00
co.UseDllForSystemUnits := false;
comp.ErrorsList.Clear();
comp.Warnings.Clear();
comp.Compile(co);
if comp.ErrorsList.Count > 0 then
begin
2021-01-05 14:32:21 +03:00
if nogui then
raise new Exception('Compilation of ' + files[i] + ' failed' + System.Environment.NewLine + comp.ErrorsList[0].ToString());
2018-06-03 20:49:55 +03:00
System.Windows.Forms.MessageBox.Show('Compilation of ' + files[i] + ' failed' + System.Environment.NewLine + comp.ErrorsList[0].ToString());
2015-05-14 22:35:07 +03:00
Halt();
end;
end;
2018-01-30 22:39:20 +03:00
System.GC.Collect;
2015-05-14 22:35:07 +03:00
end;
procedure CopyPCUFiles;
begin
var dir := TestSuiteDir + PathSeparator + 'units';
if not Directory.Exists(dir) then exit;
var files := Directory.GetFiles(dir, '*.pcu');
2015-05-14 22:35:07 +03:00
foreach fname: string in files do
begin
2018-06-03 20:49:55 +03:00
&File.Move(fname, TestSuiteDir + PathSeparator + 'usesunits' + PathSeparator + Path.GetFileName(fname));
2015-05-14 22:35:07 +03:00
end;
end;
procedure RunAllTests(redirectIO: boolean);
begin
2020-12-26 20:05:31 +03:00
var dlls := Directory.GetFiles(TestSuiteDir, '*.dll');
foreach var dll in dlls do
begin
System.IO.File.Copy(dll, TestSuiteDir + PathSeparator + 'exe' + PathSeparator + Path.GetFileName(dll), true);
end;
var dir := TestSuiteDir + PathSeparator + 'exe';
if not Directory.Exists(dir) then exit;
var files := Directory.GetFiles(dir, '*.exe');
2015-05-14 22:35:07 +03:00
for var i := 0 to files.Length - 1 do
begin
//Println(files[i]);
2018-06-03 20:49:55 +03:00
var psi := new System.Diagnostics.ProcessStartInfo(files[i]);
psi.CreateNoWindow := true;
psi.UseShellExecute := false;
psi.WorkingDirectory := TestSuiteDir + PathSeparator + 'exe';
2015-05-14 22:35:07 +03:00
{psi.RedirectStandardInput := true;
psi.RedirectStandardOutput := true;
psi.RedirectStandardError := true;}
2018-06-03 20:49:55 +03:00
var p: Process := new Process();
p.StartInfo := psi;
p.Start();
if redirectIO then
p.StandardInput.WriteLine('GO');
2015-05-14 22:35:07 +03:00
//p.StandardInput.AutoFlush := true;
//var p := System.Diagnostics.Process.Start(psi);
if nogui then
2021-01-05 15:50:31 +03:00
begin
var success := p.WaitForExit(60000);
if not success then
begin
raise new Exception('Running of ' + files[i] + ' failed.');
end;
end
else
p.WaitForExit();
2021-01-02 16:49:05 +03:00
//while not p.HasExited do
// Sleep(5);
2018-06-03 20:49:55 +03:00
if p.ExitCode <> 0 then
begin
2021-01-05 14:32:21 +03:00
if nogui then
raise new Exception('Running of ' + files[i] + ' failed. Exit code is not 0');
2018-06-03 20:49:55 +03:00
System.Windows.Forms.MessageBox.Show('Running of ' + files[i] + ' failed. Exit code is not 0');
Halt;
end;
2015-05-14 22:35:07 +03:00
end;
end;
procedure RunExpressionsExtractTests;
begin
// Пока для других языков не поддерживается
if CurrentLanguageInfo.languageName <> 'PascalABC.NET' then exit;
CodeCompletion.CodeCompletionTester.Test();
2015-05-14 22:35:07 +03:00
end;
2016-05-06 14:56:19 +03:00
function GetLineByPos(lines: array of string; pos: integer): integer;
begin
var cum_pos := 0;
for var i := 0 to lines.Length - 1 do
2018-06-03 20:49:55 +03:00
for var j := 0 to lines[j].Length - 1 do
2016-05-06 14:56:19 +03:00
begin
2018-06-03 20:49:55 +03:00
if cum_pos = pos then
begin
Result := i + 1;
exit;
end;
Inc(cum_pos);
2016-05-06 14:56:19 +03:00
end;
end;
function GetColByPos(lines: array of string; pos: integer): integer;
begin
var cum_pos := 0;
for var i := 0 to lines.Length - 1 do
2018-06-03 20:49:55 +03:00
for var j := 0 to lines[j].Length - 1 do
2016-05-06 14:56:19 +03:00
begin
2018-06-03 20:49:55 +03:00
if cum_pos = pos then
begin
Result := j + 1;
exit;
end;
Inc(cum_pos);
2016-05-06 14:56:19 +03:00
end;
end;
procedure RunIntellisenseTests;
begin
var dir := TestSuiteDir + PathSeparator + 'intellisense_tests';
if not Directory.Exists(dir) then exit;
2016-05-06 14:56:19 +03:00
PascalABCCompiler.StringResourcesLanguage.CurrentTwoLetterISO := 'ru';
CodeCompletion.CodeCompletionTester.TestIntellisense(dir);
2016-05-06 14:56:19 +03:00
end;
2015-05-14 22:35:07 +03:00
procedure RunFormatterTests;
begin
var dir := TestSuiteDir + PathSeparator + 'formatter_tests';
if not Directory.Exists(dir) then exit;
2015-05-14 22:35:07 +03:00
CodeCompletion.FormatterTester.Test();
var errors := &File.ReadAllText(dir + PathSeparator + 'output' + PathSeparator + 'log.txt');
2015-05-14 22:35:07 +03:00
if not string.IsNullOrEmpty(errors) then
begin
var dirInfo := new DirectoryInfo(TestSuiteDir);
if nogui then
raise new Exception('Formatter tests failed.' + NewLine + errors);
System.Windows.Forms.MessageBox.Show(errors + System.Environment.NewLine + $'more info at {dirInfo.Parent.Name}/{dirInfo.Name}/formatter_tests/output/log.txt');
2015-05-14 22:35:07 +03:00
Halt;
end;
end;
procedure ClearDirByPattern(dir, pattern: string);
begin
2023-08-14 00:17:35 +03:00
if not Directory.Exists(dir) then exit;
2015-05-14 22:35:07 +03:00
var files := Directory.GetFiles(dir, pattern);
for var i := 0 to files.Length - 1 do
begin
try
2015-05-15 12:35:40 +03:00
if Path.GetFileName(files[i]) <> '.gitignore' then
&File.Delete(files[i]);
2015-05-14 22:35:07 +03:00
except
end;
end;
end;
procedure ClearExeDir;
begin
2018-06-03 20:49:55 +03:00
ClearDirByPattern(TestSuiteDir + PathSeparator + 'exe', '*.*');
ClearDirByPattern(TestSuiteDir + PathSeparator + 'CompilationSamples', '*.exe');
ClearDirByPattern(TestSuiteDir + PathSeparator + 'CompilationSamples', '*.mdb');
ClearDirByPattern(TestSuiteDir + PathSeparator + 'CompilationSamples', '*.pdb');
ClearDirByPattern(TestSuiteDir + PathSeparator + 'CompilationSamples', '*.pcu');
ClearDirByPattern(TestSuiteDir + PathSeparator + 'pabcrtl_tests', '*.exe');
ClearDirByPattern(TestSuiteDir + PathSeparator + 'pabcrtl_tests', '*.pdb');
ClearDirByPattern(TestSuiteDir + PathSeparator + 'pabcrtl_tests', '*.mdb');
ClearDirByPattern(TestSuiteDir + PathSeparator + 'pabcrtl_tests', '*.pcu');
2015-05-14 22:35:07 +03:00
end;
procedure DeletePCUFiles;
begin
2018-06-03 20:49:55 +03:00
ClearDirByPattern(TestSuiteDir + PathSeparator + 'usesunits', '*.pcu');
2015-05-14 22:35:07 +03:00
end;
//procedure DeletePABCSystemPCU;
//begin
// var dir := Path.Combine(Path.GetDirectoryName(GetEXEFileName()), 'Lib');
// var pcu := Path.Combine(dir, 'PABCSystem.pcu');
//end;
/// Копирует всю папку CodeExamples в TestSuite (если такая уже есть, то предварительно удаляет её)
procedure CopyCodeExamples;
2015-05-14 22:35:07 +03:00
begin
var dir := GetCodeExamplesDir();
if not Directory.Exists(dir) then exit;
var files := GetFilesByExtensions(dir, CurrentLanguageInfo.languageExtensions, SearchOption.AllDirectories);
var destinationDir := TestSuiteDir + PathSeparator + 'CodeExamples' + PathSeparator;
if Directory.Exists(destinationDir) then
Directory.Delete(destinationDir, True);
Directory.CreateDirectory(destinationDir);
2015-05-14 22:35:07 +03:00
foreach f: string in files do
begin
&File.Copy(f, destinationDir + Path.GetFileName(f), true);
2015-05-14 22:35:07 +03:00
end;
end;
function MsToMinutes(ms: integer) : string;
begin
var span := System.TimeSpan.FromMilliseconds(ms);
Result := span.Minutes > 0 ? $'{span.Minutes}m {span.Seconds}s' : $'{span.Seconds}s';
end;
2015-05-14 22:35:07 +03:00
begin
//DeletePABCSystemPCU;
try
Languages.Integration.LanguageIntegrator.LoadAllLanguages();
Implement programming languages integration functionality (#3001) * Make standardModules Dictionary instead of LanguageId usage * Create new common string constants for pascal language * Add LanguagesData class template * Move some compiler directive string constants to Compiler project * Extract LanguagesData class to separate file Also extracted RuntimeServiceModule (IO-modules) management to new functions. * Fix pabcnetc crashing (KeyNotFoundException) * Make similar change in pabcnetc_clear * Return PABCExtensions in DomConverter.cs * Return compiler string constants to Tree Converter * Rename MoveSystemUnitForward method * Rename system unit variable * Add new parser load error (localized versions) * Fix pascal language name constant * Add system units property to parsers * Add LanguageKits directory with a test file * Implement language integrator Был реализован загрузчик комплектов дополнительных языков (всех кроме Pascal). Был пересмотрен подход к реализации ParsersController и этот класс сделан синглтоном. Добавлена загрузка стандартных модулей языков в CompilerOptions. * Squashed commit of the following: commit 8f9dc7e5a0dbe2516a2af44d8ef843b7c30e2292 Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Mon Mar 11 20:33:13 2024 +0300 fix #3050 commit 90363ced454216ef44c4919bb694b1a2c786b4b5 Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Sun Mar 3 21:37:25 2024 +0300 Недобитки при сортировке строк commit c9d7ba7758d1cb4f41348f5cc9095b0350e0c005 Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Sat Mar 2 13:32:14 2024 +0300 Order и OrderDescending для строк с Ordinal commit 6fbc0200bf4b413940a459f8b5d96c4597f561f4 Author: AlexanderZemlyak <92867056+AlexanderZemlyak@users.noreply.github.com> Date: Tue Feb 27 23:21:26 2024 +0300 Fix interface loop dependency check (#3047) Tests for problematic case were added commit e4d63bfef9ef22c3a21375b542d5540a593916e5 Author: bormant <bormant@mail.ru> Date: Tue Feb 27 23:18:25 2024 +0300 Fix typo: C (ru) -> C (en) (#3042) commit 0d37232d21ce81d3443ad680b21b865a2b2fe017 Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Tue Feb 27 19:15:08 2024 +0300 School - исправление пустого диапазона простых и IP-адресов commit 9fd4c7f3388b7e9b5cd6dbae1d619fa11827e30d Merge: 3cca2a89 6027083b Author: Ivan Bondarev <ibond84@googlemail.com> Date: Wed Feb 21 20:57:10 2024 +0100 Merge branch 'master' of https://github.com/pascalabcnet/pascalabcnet commit 3cca2a894940cf585772464d55ac5f4bcf8e01ae Author: Ivan Bondarev <ibond84@googlemail.com> Date: Wed Feb 21 20:56:49 2024 +0100 fix in formatter
2024-03-13 22:16:40 +03:00
TestSuiteDir := System.Environment.CurrentDirectory;
System.Environment.CurrentDirectory := Path.GetDirectoryName(GetEXEFileName());
CurrentLanguageInfo := GetCurrentLanguageInfo(TestSuiteDir);
if (ParamCount = 0) or (ParamStr(1) = '1') then
Println($'----- {CurrentLanguageInfo.languageName} тесты -----');
2021-01-05 14:32:21 +03:00
if (ParamCount = 2) and (ParamStr(2) = '1') then
nogui := true;
2018-06-03 20:49:55 +03:00
if (ParamCount = 0) or (ParamStr(1) = '1') then
begin
Println('Compiling tests...');
2018-06-03 20:49:55 +03:00
DeletePCUFiles;
ClearExeDir;
CompileAllRunTests(false);
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
2018-06-03 20:49:55 +03:00
end;
if (ParamCount = 0) or (ParamStr(1) = '2') then
begin
Println('Compiling compilation samples...');
CopyCodeExamples;
CompileAllCompilationTests('CodeExamples', false);
2018-06-03 20:49:55 +03:00
CompileAllCompilationTests('CompilationSamples', false);
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
2018-06-03 20:49:55 +03:00
end;
if (ParamCount = 0) or (ParamStr(1) = '3') then
begin
Println('Compiling tests with multiple units and error throwing tests...');
2018-06-03 20:49:55 +03:00
CompileAllUnits;
CopyPCUFiles;
CompileAllUsesUnits;
CompileErrorTests(false);
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
2018-06-03 20:49:55 +03:00
end;
if (ParamCount = 0) or (ParamStr(1) = '4') then
begin
Println('Running tests...');
2018-06-03 20:49:55 +03:00
RunAllTests(false);
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
2018-06-03 20:49:55 +03:00
ClearExeDir;
DeletePCUFiles;
end;
if (ParamCount = 0) or (ParamStr(1) = '5') then
begin
Println('Compiling tests in 32bit mode...');
CompileAllRunTests(false, true);
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
Println('Running tests in 32bit mode...');
RunAllTests(false);
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
ClearExeDir;
Println('Compiling tests with PABCRtl.dll...');
CompileAllRunTests(true);
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
Println('Compiling compilation samples with PABCRtl.dll...');
CompileAllCompilationTests('pabcrtl_tests', true);
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
2019-10-06 13:38:27 +03:00
end;
if (ParamCount = 0) or (ParamStr(1) = '6') then
begin
Println('Running tests with PABCRtl.dll...');
2019-10-06 13:38:27 +03:00
RunAllTests(false);
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
Println('Running intellisense expression tests...');
2018-06-03 20:49:55 +03:00
RunExpressionsExtractTests;
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
Println('Running basic intellisense tests...');
2018-06-03 20:49:55 +03:00
RunIntellisenseTests;
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
Println('Running formatter tests...');
2018-06-03 20:49:55 +03:00
RunFormatterTests;
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
2018-06-03 20:49:55 +03:00
end;
except
on e: Exception do
2021-01-05 14:53:09 +03:00
begin
if nogui then
raise new Exception(e.ToString());
2018-06-03 20:49:55 +03:00
assert(false, e.ToString());
2021-01-05 14:53:09 +03:00
end;
end;
2015-05-14 22:35:07 +03:00
end.