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(Int argc, const char** argv): Context(Configuration{}, argc, argv) {}
Context::Context(NoCreateT, Int argc, const char** argv) noexcept: _device{}, _context{} { 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") args.addOption("log", "default").setHelp("log", "console logging", "default|quiet|verbose")
.setFromEnvironment("log") .setFromEnvironment("log")
.parse(argc, argv); .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 options passed to the application itself. Options that don't have this prefix
are completely ignored, see documentation of the are completely ignored, see documentation of the
@ref Utility-Arguments-delegating "Utility::Arguments" class for details. @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 { class MAGNUM_AUDIO_EXPORT Context {
public: public:

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

@ -40,6 +40,7 @@ struct ContextALTest: TestSuite::Tester {
void constructMove(); void constructMove();
void quietLog(); void quietLog();
void ignoreUnrelatedOptions();
void extensionsString(); void extensionsString();
void isExtensionEnabled(); void isExtensionEnabled();
@ -51,7 +52,8 @@ ContextALTest::ContextALTest() {
addInstancedTests({&ContextALTest::quietLog}, 2); addInstancedTests({&ContextALTest::quietLog}, 2);
addTests({&ContextALTest::extensionsString, addTests({&ContextALTest::ignoreUnrelatedOptions,
&ContextALTest::extensionsString,
&ContextALTest::isExtensionEnabled}); &ContextALTest::isExtensionEnabled});
} }
@ -90,6 +92,13 @@ void ContextALTest::quietLog() {
CORRADE_COMPARE(out.str().empty(), bool(testCaseInstanceId())); 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() { void ContextALTest::extensionsString() {
Context context; Context context;

Loading…
Cancel
Save