mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-23 18:41:37 +02:00
codetools: started parsing pas2js output
git-svn-id: trunk@57845 -
This commit is contained in:
parent
7943f543f2
commit
2e95e24d2f
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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/testcompleteblock.pas svneol=native#text/plain
|
||||||
components/codetools/tests/testcompreaderwriterpas.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/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/testctrangescan.pas svneol=native#text/plain
|
||||||
components/codetools/tests/testctxmlfixfragments.pas svneol=native#text/pascal
|
components/codetools/tests/testctxmlfixfragments.pas svneol=native#text/pascal
|
||||||
components/codetools/tests/testfinddeclaration.pas svneol=native#text/plain
|
components/codetools/tests/testfinddeclaration.pas svneol=native#text/plain
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
<PackageName Value="fpcunitconsolerunner"/>
|
<PackageName Value="fpcunitconsolerunner"/>
|
||||||
</Item2>
|
</Item2>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="14">
|
<Units Count="15">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="runtestscodetools.lpr"/>
|
<Filename Value="runtestscodetools.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
@ -105,6 +105,11 @@
|
|||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="TestIdentCompletion"/>
|
<UnitName Value="TestIdentCompletion"/>
|
||||||
</Unit13>
|
</Unit13>
|
||||||
|
<Unit14>
|
||||||
|
<Filename Value="testctpas2js.pas"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="TestCTPas2js"/>
|
||||||
|
</Unit14>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
|
@ -39,7 +39,7 @@ uses
|
|||||||
TestBasicCodetools, TestCTRangeScan, TestPascalParser, TestMethodJumpTool,
|
TestBasicCodetools, TestCTRangeScan, TestPascalParser, TestMethodJumpTool,
|
||||||
TestStdCodetools, TestFindDeclaration, TestIdentCompletion, TestCompleteBlock,
|
TestStdCodetools, TestFindDeclaration, TestIdentCompletion, TestCompleteBlock,
|
||||||
TestRefactoring, TestCodeCompletion, TestCompReaderWriterPas,
|
TestRefactoring, TestCodeCompletion, TestCompReaderWriterPas,
|
||||||
fdt_arrays;
|
fdt_arrays, TestCTPas2js;
|
||||||
|
|
||||||
const
|
const
|
||||||
ConfigFilename = 'codetools.config';
|
ConfigFilename = 'codetools.config';
|
||||||
|
102
components/codetools/tests/testctpas2js.pas
Normal file
102
components/codetools/tests/testctpas2js.pas
Normal 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.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user