Browse Source

Audio: ignore command-line options not related to audio.

pull/364/head
Vladimír Vondruš 7 years ago
parent
commit
2c280f6b97
  1. 3
      src/Magnum/Audio/Context.cpp
  2. 4
      src/Magnum/Audio/Context.h
  3. 11
      src/Magnum/Audio/Test/ContextALTest.cpp

3
src/Magnum/Audio/Context.cpp

@ -125,7 +125,8 @@ Context& Context::current() {
Context::Context(Int argc, const char** argv): Context(Configuration{}, argc, argv) {}
Context::Context(NoCreateT, Int argc, const char** argv) noexcept: _device{}, _context{} {
Utility::Arguments args{"magnum"};
Utility::Arguments args{"magnum",
Utility::Arguments::Flag::IgnoreUnknownOptions};
args.addOption("log", "default").setHelp("log", "console logging", "default|quiet|verbose")
.setFromEnvironment("log")
.parse(argc, argv);

4
src/Magnum/Audio/Context.h

@ -105,6 +105,10 @@ Note that all options are prefixed with `--magnum-` to avoid conflicts with
options passed to the application itself. Options that don't have this prefix
are completely ignored, see documentation of the
@ref Utility-Arguments-delegating "Utility::Arguments" class for details.
Moreover, `--magnum`-prefixed options unrelated to audio (such as those defined
by @ref GL-Context-command-line "GL::Context") are ignored as well. In order to
provide a complete help and command-line argument diagnostic, you should
instantiate this class *after* @ref GL::Context.
*/
class MAGNUM_AUDIO_EXPORT Context {
public:

11
src/Magnum/Audio/Test/ContextALTest.cpp

@ -40,6 +40,7 @@ struct ContextALTest: TestSuite::Tester {
void constructMove();
void quietLog();
void ignoreUnrelatedOptions();
void extensionsString();
void isExtensionEnabled();
@ -51,7 +52,8 @@ ContextALTest::ContextALTest() {
addInstancedTests({&ContextALTest::quietLog}, 2);
addTests({&ContextALTest::extensionsString,
addTests({&ContextALTest::ignoreUnrelatedOptions,
&ContextALTest::extensionsString,
&ContextALTest::isExtensionEnabled});
}
@ -90,6 +92,13 @@ void ContextALTest::quietLog() {
CORRADE_COMPARE(out.str().empty(), bool(testCaseInstanceId()));
}
void ContextALTest::ignoreUnrelatedOptions() {
const char* argv[] = { "", "--magnum-gpu-validation", "on" };
Context context{Containers::arraySize(argv), argv};
CORRADE_VERIFY(Context::hasCurrent());
}
void ContextALTest::extensionsString() {
Context context;

Loading…
Cancel
Save