codetools: started parsing pas2js output

git-svn-id: trunk@57845 -
This commit is contained in:
mattias 2018-05-08 17:00:20 +00:00
parent 7943f543f2
commit 2e95e24d2f
4 changed files with 110 additions and 2 deletions

1
.gitattributes vendored
View File

@ -969,6 +969,7 @@ components/codetools/tests/testcodecompletion.pas svneol=native#text/plain
components/codetools/tests/testcompleteblock.pas svneol=native#text/plain
components/codetools/tests/testcompreaderwriterpas.pas svneol=native#text/plain
components/codetools/tests/testcth2pas.pas svneol=native#text/pascal
components/codetools/tests/testctpas2js.pas svneol=native#text/plain
components/codetools/tests/testctrangescan.pas svneol=native#text/plain
components/codetools/tests/testctxmlfixfragments.pas svneol=native#text/pascal
components/codetools/tests/testfinddeclaration.pas svneol=native#text/plain

View File

@ -38,7 +38,7 @@
<PackageName Value="fpcunitconsolerunner"/>
</Item2>
</RequiredPackages>
<Units Count="14">
<Units Count="15">
<Unit0>
<Filename Value="runtestscodetools.lpr"/>
<IsPartOfProject Value="True"/>
@ -105,6 +105,11 @@
<IsPartOfProject Value="True"/>
<UnitName Value="TestIdentCompletion"/>
</Unit13>
<Unit14>
<Filename Value="testctpas2js.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="TestCTPas2js"/>
</Unit14>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -39,7 +39,7 @@ uses
TestBasicCodetools, TestCTRangeScan, TestPascalParser, TestMethodJumpTool,
TestStdCodetools, TestFindDeclaration, TestIdentCompletion, TestCompleteBlock,
TestRefactoring, TestCodeCompletion, TestCompReaderWriterPas,
fdt_arrays;
fdt_arrays, TestCTPas2js;
const
ConfigFilename = 'codetools.config';

View File

@ -0,0 +1,102 @@
{
Test all with:
./runtests --format=plain --suite=TTestPas2js
Test specific with:
./runtests --format=plain --suite=TestPas2js_ReadSettings
}
unit TestCTPas2js;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, CodeToolManager, FileProcs, DefineTemplates, LinkScanner,
LazLogger, LazFileUtils, LazUTF8, fpcunit, testregistry;
type
{ TCustomTestPas2js }
TCustomTestPas2js = class(TTestCase)
private
FAutoSearchPas2js: boolean;
FPas2jsFilename: string;
protected
procedure SetUp; override;
procedure TearDown; override;
public
constructor Create; override;
function FindPas2js: string;
property AutoSearchPas2js: boolean read FAutoSearchPas2js write FAutoSearchPas2js;
property Pas2jsFilename: string read FPas2jsFilename write FPas2jsFilename;
end;
{ TTestPas2js }
TTestPas2js = class(TCustomTestPas2js)
published
procedure TestPas2js_ReadSettings;
end;
implementation
{ TCustomTestPas2js }
procedure TCustomTestPas2js.SetUp;
begin
inherited SetUp;
if (Pas2jsFilename='') and AutoSearchPas2js then begin
FPas2jsFilename:=FindPas2js;
AutoSearchPas2js:=false;
end;
//CodeToolBoss.CompilerDefinesCache;
end;
procedure TCustomTestPas2js.TearDown;
begin
inherited TearDown;
end;
constructor TCustomTestPas2js.Create;
begin
inherited Create;
FAutoSearchPas2js:=true;
end;
function TCustomTestPas2js.FindPas2js: string;
var
ShortFilename: String;
begin
Result:=GetEnvironmentVariable('PAS2JS');
if Result<>'' then begin
if not FileExistsUTF8(Result) then
Fail('Environment variable PAS2JS has non existing "'+Result+'"');
exit;
end;
ShortFilename:='pas2js'+ExeExt;
Result:=SearchFileInPath(ShortFilename,'',
GetEnvironmentVariableUTF8('PATH'),PathSeparator,ctsfcDefault);
end;
{ TTestPas2js }
procedure TTestPas2js.TestPas2js_ReadSettings;
var
UnitSetCache: TFPCUnitSetCache;
begin
if Pas2jsFilename='' then exit;
exit;
UnitSetCache:=CodeToolBoss.CompilerDefinesCache.FindUnitSet(Pas2jsFilename,
'','','','',true);
// parse compiler settings
UnitSetCache.Init;
AssertEquals('compiler kind',dbgs(pcPas2js),dbgs(UnitSetCache.GetCompilerKind));
end;
initialization
RegisterTest(TTestPas2js);
end.