mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-23 11:32:07 +00:00
Implement -c #none (#1301)
Also adds a test case for round-tripping `-r` with `-c #none`.
This commit is contained in:
4
test/gfx/none_comma_ommission.err
Normal file
4
test/gfx/none_comma_ommission.err
Normal file
@@ -0,0 +1,4 @@
|
||||
error: Unexpected character, expected ',', ';', or end of argument
|
||||
In inline palette spec: #000,#none#fff
|
||||
^
|
||||
Conversion aborted after 1 error
|
||||
1
test/gfx/none_comma_ommission.flags
Normal file
1
test/gfx/none_comma_ommission.flags
Normal file
@@ -0,0 +1 @@
|
||||
-c #000,#none#fff
|
||||
BIN
test/gfx/none_comma_ommission.png
Normal file
BIN
test/gfx/none_comma_ommission.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 581 B |
BIN
test/gfx/none_round_trip.2bpp
Normal file
BIN
test/gfx/none_round_trip.2bpp
Normal file
Binary file not shown.
@@ -281,6 +281,21 @@ public:
|
||||
};
|
||||
|
||||
static char *execProg(char const *name, char * const *argv) {
|
||||
auto formatArgv = [&argv] {
|
||||
// This is `static` so that the returned `buf.c_str()` will live long enough
|
||||
// for `fatal()` to use it below.
|
||||
static std::string buf;
|
||||
|
||||
buf.clear();
|
||||
for (char * const *arg = argv; *arg != nullptr; ++arg) {
|
||||
buf.push_back('"');
|
||||
buf.append(*arg);
|
||||
buf.append("\", ");
|
||||
}
|
||||
buf.resize(buf.length() - 2);
|
||||
return buf.c_str();
|
||||
};
|
||||
|
||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
pid_t pid;
|
||||
int err = posix_spawn(&pid, argv[0], nullptr, nullptr, argv, nullptr);
|
||||
@@ -293,10 +308,10 @@ static char *execProg(char const *name, char * const *argv) {
|
||||
fatal("Error waiting for %s: %s", name, strerror(errno));
|
||||
} else if (info.si_code != CLD_EXITED) {
|
||||
assert(info.si_code == CLD_KILLED || info.si_code == CLD_DUMPED);
|
||||
fatal("%s was terminated by signal %s%s", name, strsignal(info.si_status),
|
||||
info.si_code == CLD_DUMPED ? " (core dumped)" : "");
|
||||
fatal("%s was terminated by signal %s%s\n\tThe command was: [%s]", name, strsignal(info.si_status),
|
||||
info.si_code == CLD_DUMPED ? " (core dumped)" : "", formatArgv());
|
||||
} else if (info.si_status != 0) {
|
||||
fatal("%s returned with status %d", name, info.si_status);
|
||||
fatal("%s returned with status %d\n\tThe command was: [%s]", name, info.si_status, formatArgv());
|
||||
}
|
||||
|
||||
#else // defined(_MSC_VER) || defined(__MINGW32__)
|
||||
@@ -362,7 +377,7 @@ static char *execProg(char const *name, char * const *argv) {
|
||||
CloseHandle(child.hThread);
|
||||
|
||||
if (status != 0) {
|
||||
fatal("%s returned with status %ld", name, status);
|
||||
fatal("%s returned with status %ld\n\tThe command was: [%s]", name, status, formatArgv());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -39,8 +39,15 @@ for f in *.bin; do
|
||||
done
|
||||
done
|
||||
|
||||
# Test round-tripping '-r' with '-c #none'
|
||||
reverse_cmd="$RGBGFX -c#none,#fff,#000 -o none_round_trip.2bpp -r 1 out.png"
|
||||
reconvert_cmd="$RGBGFX -c#none,#fff,#000 -o result.2bpp out.png"
|
||||
compare_cmd="cmp none_round_trip.2bpp result.2bpp"
|
||||
new_test "$reverse_cmd && $reconvert_cmd && $compare_cmd"
|
||||
test || fail $?
|
||||
|
||||
# Remove temporaries (also ignored by Git) created by the above tests
|
||||
rm -f out*.png result.png
|
||||
rm -f out*.png result.png result.2bpp
|
||||
|
||||
for f in *.png; do
|
||||
flags="$([[ -e "${f%.png}.flags" ]] && echo "@${f%.png}.flags")"
|
||||
|
||||
Reference in New Issue
Block a user