Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
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
cpp-libs
Actor Framework
Commits
a2b37ee1
Commit
a2b37ee1
authored
Aug 05, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly store CLI remainder in config
parent
04ba5ea6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
6 deletions
+102
-6
libcaf_core/caf/actor_system_config.hpp
libcaf_core/caf/actor_system_config.hpp
+1
-1
libcaf_core/src/actor_system_config.cpp
libcaf_core/src/actor_system_config.cpp
+1
-5
libcaf_core/test/actor_system_config.cpp
libcaf_core/test/actor_system_config.cpp
+100
-0
No files found.
libcaf_core/caf/actor_system_config.hpp
View file @
a2b37ee1
...
@@ -350,7 +350,7 @@ private:
...
@@ -350,7 +350,7 @@ private:
error
adjust_content
();
error
adjust_content
();
};
};
///
@private
///
Returns all user-provided configuration parameters.
const
settings
&
content
(
const
actor_system_config
&
cfg
);
const
settings
&
content
(
const
actor_system_config
&
cfg
);
/// Tries to retrieve the value associated to `name` from `cfg`.
/// Tries to retrieve the value associated to `name` from `cfg`.
...
...
libcaf_core/src/actor_system_config.cpp
View file @
a2b37ee1
...
@@ -254,12 +254,8 @@ error actor_system_config::parse(string_list args, std::istream& ini) {
...
@@ -254,12 +254,8 @@ error actor_system_config::parse(string_list args, std::istream& ini) {
using
std
::
make_move_iterator
;
using
std
::
make_move_iterator
;
auto
res
=
custom_options_
.
parse
(
content
,
args
);
auto
res
=
custom_options_
.
parse
(
content
,
args
);
if
(
res
.
second
!=
args
.
end
())
{
if
(
res
.
second
!=
args
.
end
())
{
if
(
res
.
first
!=
pec
::
success
)
{
if
(
res
.
first
!=
pec
::
success
&&
starts_with
(
*
res
.
second
,
"-"
))
return
make_error
(
res
.
first
,
*
res
.
second
);
return
make_error
(
res
.
first
,
*
res
.
second
);
std
::
cerr
<<
"error: at argument
\"
"
<<
*
res
.
second
<<
"
\"
: "
<<
to_string
(
res
.
first
)
<<
std
::
endl
;
cli_helptext_printed
=
true
;
}
auto
first
=
args
.
begin
();
auto
first
=
args
.
begin
();
first
+=
std
::
distance
(
args
.
cbegin
(),
res
.
second
);
first
+=
std
::
distance
(
args
.
cbegin
(),
res
.
second
);
remainder
.
insert
(
remainder
.
end
(),
make_move_iterator
(
first
),
remainder
.
insert
(
remainder
.
end
(),
make_move_iterator
(
first
),
...
...
libcaf_core/test/actor_system_config.cpp
0 → 100644
View file @
a2b37ee1
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2019 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#define CAF_SUITE actor_system_config
#include "caf/actor_system_config.hpp"
#include "caf/test/dsl.hpp"
#include <sstream>
#include <string>
#include <vector>
using
namespace
caf
;
namespace
{
using
string_list
=
std
::
vector
<
std
::
string
>
;
struct
config
:
actor_system_config
{
config
()
{
opt_group
{
custom_options_
,
"?foo"
}
.
add
<
std
::
string
>
(
"bar,b"
,
"some string parameter"
);
}
};
struct
fixture
{
fixture
()
{
ini
<<
"[foo]
\n
bar=
\"
hello
\"
"
;
}
error
parse
(
string_list
args
)
{
opts
.
clear
();
remainder
.
clear
();
config
cfg
;
auto
result
=
cfg
.
parse
(
std
::
move
(
args
),
ini
);
opts
=
content
(
cfg
);
remainder
=
cfg
.
remainder
;
return
result
;
}
std
::
stringstream
ini
;
settings
opts
;
std
::
vector
<
std
::
string
>
remainder
;
};
}
// namespace
CAF_TEST_FIXTURE_SCOPE
(
actor_system_config_tests
,
fixture
)
CAF_TEST
(
parsing
-
without
CLI
arguments
)
{
CAF_CHECK_EQUAL
(
parse
({}),
none
);
CAF_CHECK
(
remainder
.
empty
());
CAF_CHECK_EQUAL
(
get_or
(
opts
,
"foo.bar"
,
""
),
"hello"
);
}
CAF_TEST
(
parsing
-
without
CLI
remainder
)
{
CAF_MESSAGE
(
"CLI long name"
);
CAF_CHECK_EQUAL
(
parse
({
"--foo.bar=test"
}),
none
);
CAF_CHECK
(
remainder
.
empty
());
CAF_CHECK_EQUAL
(
get_or
(
opts
,
"foo.bar"
,
""
),
"test"
);
CAF_MESSAGE
(
"CLI abbreviated long name"
);
CAF_CHECK_EQUAL
(
parse
({
"--bar=test"
}),
none
);
CAF_CHECK
(
remainder
.
empty
());
CAF_CHECK_EQUAL
(
get_or
(
opts
,
"foo.bar"
,
""
),
"test"
);
CAF_MESSAGE
(
"CLI short name"
);
CAF_CHECK_EQUAL
(
parse
({
"-b"
,
"test"
}),
none
);
CAF_CHECK
(
remainder
.
empty
());
CAF_CHECK_EQUAL
(
get_or
(
opts
,
"foo.bar"
,
""
),
"test"
);
CAF_MESSAGE
(
"CLI short name without whitespace"
);
CAF_CHECK_EQUAL
(
parse
({
"-btest"
}),
none
);
CAF_CHECK
(
remainder
.
empty
());
CAF_CHECK_EQUAL
(
get_or
(
opts
,
"foo.bar"
,
""
),
"test"
);
}
CAF_TEST
(
parsing
-
with
CLI
remainder
)
{
CAF_MESSAGE
(
"valid remainder"
);
CAF_CHECK_EQUAL
(
parse
({
"-b"
,
"test"
,
"hello"
,
"world"
}),
none
);
CAF_CHECK_EQUAL
(
get_or
(
opts
,
"foo.bar"
,
""
),
"test"
);
CAF_CHECK_EQUAL
(
remainder
,
string_list
({
"hello"
,
"world"
}));
CAF_MESSAGE
(
"invalid remainder"
);
CAF_CHECK_NOT_EQUAL
(
parse
({
"-b"
,
"test"
,
"-abc"
}),
none
);
}
CAF_TEST_FIXTURE_SCOPE_END
()
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