Skip to content

Commit fb9a6af

Browse files
PerMacmbolivar-ampere
authored andcommitted
scripts: west_commands: Allow passing source dir when looking for test
Before, only following way of getting test-item build was supported: `west build -b <BOARD> -T <PATH_TO_SOURCE/TEST_NAME>` This commit allows to also call it by: `west build -b <BOARD> <PATH_TO_SOURCE> -T <TEST_NAME>` Signed-off-by: Maciej Perkowski <[email protected]>
1 parent 46fcaa3 commit fb9a6af

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scripts/west_commands/build.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,12 @@ def do_add_parser(self, parser_adder):
123123
(try "-t usage")''')
124124
group.add_argument('-T', '--test-item',
125125
help='''Build based on test data in testcase.yaml
126-
or sample.yaml''')
126+
or sample.yaml. If source directory is not used
127+
an argument has to be defined as
128+
SOURCE_PATH/TEST_NAME.
129+
E.g. samples/hello_world/sample.basic.helloworld.
130+
If source directory is passed
131+
then "TEST_NAME" is enough.''')
127132
group.add_argument('-o', '--build-opt', default=[], action='append',
128133
help='''options to pass to the build tool
129134
(make or ninja); may be given more than once''')
@@ -165,7 +170,10 @@ def do_run(self, args, remainder):
165170
if self.args.test_item:
166171
# we get path + testitem
167172
item = os.path.basename(self.args.test_item)
168-
test_path = os.path.dirname(self.args.test_item)
173+
if self.args.source_dir:
174+
test_path = self.args.source_dir
175+
else:
176+
test_path = os.path.dirname(self.args.test_item)
169177
if test_path and os.path.exists(test_path):
170178
self.args.source_dir = test_path
171179
if not self._parse_test_item(item):

0 commit comments

Comments
 (0)