Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
afb531dc
Commit
afb531dc
authored
Feb 09, 2011
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
another script: render a card for each stylesheet
parent
aab4cbd3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
140 additions
and
38 deletions
+140
-38
tests/script/README
tests/script/README
+3
-0
tests/script/run-tests.pl
tests/script/run-tests.pl
+5
-31
tests/stylesheets/README
tests/stylesheets/README
+7
-0
tests/stylesheets/run-tests.pl
tests/stylesheets/run-tests.pl
+73
-0
tests/util/MseTestUtils.pm
tests/util/MseTestUtils.pm
+52
-7
No files found.
tests/script/README
0 → 100644
View file @
afb531dc
These tests "assert" expected stuff in the scripting language.
Tests are invoked by run-tests.pl
tests/script/run-tests.pl
View file @
afb531dc
...
@@ -5,41 +5,15 @@
...
@@ -5,41 +5,15 @@
# 2. Ensure that there are no errors
# 2. Ensure that there are no errors
use
strict
;
use
strict
;
use
File::
Find
;
use
File::
Basename
;
use
lib
"
../util/
";
use
lib
"
../util/
";
use
MseTestUtils
;
use
MseTestUtils
;
# -----------------------------------------------------------------------------
# Utility functions
# -----------------------------------------------------------------------------
# Invoke a script
sub
run_script_test
{
my
$script
=
shift
;
my
$args
=
shift
;
my
$expected
=
basename
(
$script
,"
.mse-script
")
.
"
.out.expected
";
my
$outfile
=
basename
(
$script
,"
.mse-script
")
.
"
.out
";
my
$command
=
"
$MseTestUtils
::MAGICSETEDITOR --cli --quiet --script
$script
$args
>
$outfile
";
print
"
$command
\n
";
`
$command
`;
# TODO: diff against expected output
}
sub
write_dummy_set
{
my
$setname
=
shift
;
my
$contents
=
shift
;
mkdir
(
$setname
);
open
SET
,"
>
$setname
/set
";
print
SET
"
mse version: 2.0.0
\n
";
print
SET
$contents
;
close
SET
;
}
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# The tests
# The tests
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
run_script_test
("
test-builtin1.mse-script
",
"");
run_script_test
("
test-builtin.mse-script
",
"");
write_dummy_set
("
dummy-magic-set.mse-set
",
"
game: magic
\n
stylesheet: new
\n
");
run_script_test
("
test-magic.mse-script
",
"
dummy-magic-set
");
write_dummy_set
("
_dummy-magic-set.mse-set
",
"
game: magic
\n
stylesheet: new
\n
");
run_script_test
("
test-magic.mse-script
",
"
_dummy-magic-set
");
remove_dummy_set
("
_dummy-magic-set.mse-set
");
tests/stylesheets/README
0 → 100644
View file @
afb531dc
These tests work by:
1. creating a set file for each style
2. loading that set file into magicseteditor --cli
(3. exporting a card image)
4. comparing the card image against expected output
Tests are invoked by run-tests.pl
tests/stylesheets/run-tests.pl
0 → 100644
View file @
afb531dc
#!/usr/bin/perl
# For each mse-script file:
# 1. Invoke magicseteditor
# 2. Ensure that there are no errors
use
strict
;
use
lib
"
../util/
";
use
MseTestUtils
;
use
File::
Spec
;
use
File::
Basename
;
# -----------------------------------------------------------------------------
# The tests
# -----------------------------------------------------------------------------
sub
test_stylesheet
{
my
$path
=
shift
;
(
my
$x
,
my
$y
,
my
$package
)
=
File::
Spec
->
splitpath
(
$path
);
my
$basename
=
basename
(
$package
,"
.mse-style
");
print
"
Testing
$package
\n
";
# Determine game for this set
my
$game
;
open
STYLE
,
"
<
$path
/style
";
while
(
<
STYLE
>
)
{
$game
=
$1
if
/^game: (.*)/
;
}
close
STYLE
;
die
("
No game found for
$package
")
if
!
$game
;
# Stylesheet suffix
my
$suffix
;
if
(
$package
=~
/$game-(.+).mse-style/
)
{
$suffix
=
$1
;
}
else
{
#die ("Stylesheet filename doesn't match game");
print
("
Stylesheet filename doesn't match game!
\n
");
return
;
}
print
"
game:
$game
\n
";
print
"
stylesheet:
$suffix
\n
";
# Create dummy set
my
$set
;
my
$tempname
=
"
_dummy-
$basename
";
my
$setname
=
"
$tempname
-set.mse-set
";
$set
.=
"
game:
$game
\n
";
$set
.=
"
stylesheet:
$suffix
\n
";
$set
.=
"
card:
\n
";
write_dummy_set
(
$setname
,
$set
);
# Write script
my
$script
=
"
$tempname
.mse-script
";
mkdir
("
cards-out
");
file_set_contents
(
$script
,
"
write_image_file(set.cards[0],file:
\"
cards-out/
$basename
.png
\"
);1
");
run_script_test
(
$script
,
$setname
);
# Cleanup
remove_dummy_set
(
$setname
);
unlink
(
$script
);
unlink
("
$tempname
.out
");
print
"
\n
";
}
my
$package_dir
=
"
../../data
";
my
@packages
=
glob
"
$package_dir
/*.mse-style
";
foreach
(
@packages
)
{
test_stylesheet
(
$_
);
}
tests/util/MseTestUtils.pm
View file @
afb531dc
#+----------------------------------------------------------------------------+
#+----------------------------------------------------------------------------+
#| Description: Magic Set Editor - Program to make Magic (tm) cards |
#| Description: Magic Set Editor - Program to make Magic (tm) cards |
#| Copyright: (C) 2001 - 2011 Twan van Laarhoven and Sean Hunt |
#| Copyright: (C) 2001 - 2011 Twan van Laarhoven and Sean Hunt |
#| License: GNU General Public License 2 or later (see file COPYING) |
#| License: GNU General Public License 2 or later (see file COPYING) |
#+----------------------------------------------------------------------------+
#+----------------------------------------------------------------------------+
package
MseTestUtils
;
use
strict
;
use
strict
;
use
File::
Basename
;
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Utilities for testing scripts
# Utilities for testing scripts
...
@@ -22,6 +21,52 @@ if ($is_windows) {
...
@@ -22,6 +21,52 @@ if ($is_windows) {
$MAGICSETEDITOR
=
"
../../magicseteditor
";
$MAGICSETEDITOR
=
"
../../magicseteditor
";
}
}
# Invoke a script
sub
run_script_test
{
my
$script
=
shift
;
my
$args
=
shift
;
my
$outfile
=
basename
(
$script
,"
.mse-script
")
.
"
.out
";
my
$command
=
"
$MAGICSETEDITOR
--cli --quiet --script
$script
$args
>
$outfile
";
print
"
$command
\n
";
`
$command
`;
# Check for errors / warnings
open
FILE
,"
<
$outfile
";
foreach
(
<
FILE
>
)
{
if
(
/^(WARNING|ERROR)/
)
{
print
$_
;
}
}
close
FILE
;
# TODO: diff against expected output?
#my $expected = basename($script,".mse-script") . ".out.expected";
}
# -----------------------------------------------------------------------------
# Dummy sets
# -----------------------------------------------------------------------------
sub
file_set_contents
{
my
$filename
=
shift
;
my
$contents
=
shift
;
open
FILE
,"
>
$filename
";
print
FILE
$contents
;
close
FILE
;
}
sub
write_dummy_set
{
my
$setname
=
shift
;
my
$contents
=
shift
;
mkdir
(
$setname
);
file_set_contents
("
$setname
/set
",
"
mse version: 2.0.0
\n
$contents
");
}
sub
remove_dummy_set
{
my
$setname
=
shift
;
unlink
("
$setname
/set
");
rmdir
(
$setname
);
}
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
1
;
1
;
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