Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
zilf
zilf
Commits
e1896ccfd1d3
Commit
589c853b
authored
Jan 17, 2021
by
Jesse McGrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add zillib tests to Zilf.Tests.Integration.
parent
7e4a1156220c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
7 deletions
+102
-7
test/Zilf.Tests.Integration/FullProjectTests.cs
test/Zilf.Tests.Integration/FullProjectTests.cs
+1
-1
test/Zilf.Tests.Integration/ZilLibTests.cs
test/Zilf.Tests.Integration/ZilLibTests.cs
+100
-0
test/Zilf.Tests.Integration/Zilf.Tests.Integration.csproj
test/Zilf.Tests.Integration/Zilf.Tests.Integration.csproj
+0
-5
test/Zilf.Tests.Integration/ZlrHelper.cs
test/Zilf.Tests.Integration/ZlrHelper.cs
+1
-1
No files found.
test/Zilf.Tests.Integration/FullProjectTests.cs
View file @
e1896ccf
...
...
@@ -80,7 +80,7 @@ namespace Zilf.Tests.Integration
/// <exception cref="AssertInconclusiveException">Always thrown.</exception>
[
DataTestMethod
]
[
DynamicData
(
"
GetProjects
"
,
DynamicDataSourceType
.
Method
)]
[
DynamicData
(
nameof
(
GetProjects
)
,
DynamicDataSourceType
.
Method
)]
[
Timeout
(
PerTestTimeoutMilliseconds
)]
public
void
TestProjects
(
string
baseName
,
string
dir
,
string
mainZilFile
)
{
...
...
test/Zilf.Tests.Integration/ZilLibTests.cs
0 → 100644
View file @
e1896ccf
/* Copyright 2010-2021 Jesse McGrew
*
* This file is part of ZILF.
*
* ZILF is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZILF is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZILF. If not, see <http://www.gnu.org/licenses/>.
*/
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics.CodeAnalysis
;
using
System.IO
;
using
System.Linq
;
using
System.Text.RegularExpressions
;
namespace
Zilf.Tests.Integration
{
[
TestClass
,
TestCategory
(
"Slow"
),
TestCategory
(
"Library"
)]
public
class
ZilLibTests
{
const
string
LibraryDirName
=
"zillib"
;
const
string
TestsSubDirName
=
"tests"
;
const
int
PerTestTimeoutMilliseconds
=
60000
;
static
string
testsDir
=
null
!;
static
string
libraryDir
=
null
!;
/// <exception cref="IOException">Can't locate projects and library directories</exception>
[
ClassInitialize
]
[
MemberNotNull
(
nameof
(
testsDir
),
nameof
(
libraryDir
))]
public
static
void
ClassInitialize
(
TestContext
_
)
{
testsDir
=
null
!;
libraryDir
=
null
!;
var
testsDirName
=
Path
.
Combine
(
LibraryDirName
,
TestsSubDirName
);
// find directories containing zillib/tests
var
dir
=
Directory
.
GetCurrentDirectory
();
do
{
if
(
testsDir
==
null
&&
Directory
.
Exists
(
Path
.
Combine
(
dir
,
testsDirName
)))
{
testsDir
=
Path
.
Combine
(
dir
,
testsDirName
);
libraryDir
=
Path
.
Combine
(
dir
,
LibraryDirName
);
break
;
}
dir
=
Directory
.
GetParent
(
dir
)?.
FullName
;
}
while
(
dir
!=
null
&&
dir
!=
Path
.
GetPathRoot
(
dir
));
if
(
testsDir
==
null
||
libraryDir
==
null
)
throw
new
IOException
(
"Can't locate library and tests directories"
);
}
static
IEnumerable
<
string
[
]>
GetTestCaseNames
()
{
return
from
f
in
Directory
.
EnumerateFiles
(
testsDir
,
"test-*.zil"
)
select
new
[]
{
Path
.
GetFileNameWithoutExtension
(
f
)
};
}
private
static
readonly
Regex
PassRegex
=
new
Regex
(
@"^PASS$"
,
RegexOptions
.
Multiline
);
/// <exception cref="AssertInconclusiveException">Always thrown.</exception>
[
DataTestMethod
]
[
DynamicData
(
nameof
(
GetTestCaseNames
),
DynamicDataSourceType
.
Method
)]
[
Timeout
(
PerTestTimeoutMilliseconds
)]
public
void
TestLibraryCases
(
string
testCaseName
)
{
Console
.
WriteLine
(
"Testing {0}"
,
testCaseName
);
var
mainZilFile
=
Path
.
Combine
(
testsDir
,
testCaseName
+
".zil"
);
var
helper
=
new
FileBasedZlrHelper
(
mainZilFile
,
new
[]
{
testsDir
,
libraryDir
},
null
);
Assert
.
IsTrue
(
helper
.
Compile
(),
"Failed to compile"
);
Assert
.
IsTrue
(
helper
.
Assemble
(),
"Failed to assemble"
);
var
actualOutput
=
helper
.
Execute
();
if
(!
PassRegex
.
IsMatch
(
actualOutput
))
{
Console
.
WriteLine
(
actualOutput
);
Assert
.
Fail
(
"Test case failed (output written to console)"
);
}
}
}
}
test/Zilf.Tests.Integration/Zilf.Tests.Integration.csproj
View file @
e1896ccf
...
...
@@ -13,11 +13,6 @@
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="ZLR.VM" Version="0.9.0-*" />
</ItemGroup>
<ItemGroup>
<Reference Include="ZLR.VM">
<HintPath>.\ZLR.VM.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)src\Zapf\Zapf.csproj" />
<ProjectReference Include="$(SolutionDir)src\Zilf\Zilf.csproj" />
...
...
test/Zilf.Tests.Integration/ZlrHelper.cs
View file @
e1896ccf
...
...
@@ -355,7 +355,7 @@ namespace Zilf.Tests.Integration
MemoryStream
?
zapfOutputFile
;
public
FileBasedZlrHelper
(
string
codeFile
,
string
[]
includeDirs
,
string
inputFile
)
public
FileBasedZlrHelper
(
string
codeFile
,
string
[]
includeDirs
,
string
?
inputFile
)
{
this
.
codeFile
=
codeFile
;
this
.
includeDirs
=
includeDirs
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment