Commit Graph

10 Commits

Author SHA1 Message Date
Rob Mohr
8edfeaeec0 Rename help to short_help.
Change-Id: Ibd41f06c2701b6c68a4a45c08a07c335679b976c
2019-12-09 13:45:01 -08:00
Wyatt Hepler
becb431e5f Apply pw format to the repository
Change-Id: I3c8e4f956dfe6c9e81d3069f72c30c5950852074
2019-12-05 09:31:11 -08:00
Alexei Frolov
8253ad8d66 Module to run subprocesses with captured output
This change adds a module within pw_cli that provides a function for
running a subprocess and capturing its stdout and stderr to the main
pw log. A new log level is defined for the captured output.

The pw_unit_test runner script is updated to use this function instead
of running its subprocess directly.

The pw command is updated to run its subcommand in an async context,
preventing subcommands from needing to create their own. Fully
synchronous subcommands continue to function transparently to this.

Change-Id: Ia9efb1fbda8a38ef91a0e14113929711038710a8
2019-11-27 20:34:16 +00:00
Armando Montanez
73d2972709 pw_unit_test: Add logs to indicate test start/end
Adds logs to test_runner.py that indicate the start/end of tests and
whether the test passed or failed.

The format is:
Test   8/365: [RUN] my_test
Test   8/365: [FAIL] my_test
...
Test 212/365: [RUN] my_other_test
Test 212/365: [PASS] my_other_test

Example:
20191126 11:44:41 AM INF Scanning for tests...
20191126 11:44:41 AM INF Found 4 test groups (10 tests).
20191126 11:44:41 AM INF Running test groups //pw_status:tests, //pw_preprocessor:tests, //pw_string:tests, //pw_span:tests
20191126 11:44:41 AM INF Test  1/10: [RUN] to_string_test
TEST - 2019-11-26 11:44:41 - INFO - Launching test binary out/stm32f429i-disc1/obj/pw_string/to_string_test.elf
TEST - 2019-11-26 11:44:41 - INFO - Flashing firmware to device...
TEST - 2019-11-26 11:44:43 - INFO - Successfully flashed firmware to device!
TEST - 2019-11-26 11:44:43 - INFO - Resetting device...
TEST - 2019-11-26 11:44:43 - INFO - Successfully reset device!
TEST - 2019-11-26 11:44:43 - INFO - Test passed!
20191126 11:44:43 AM INF Test  1/10: [PASS] to_string_test
20191126 11:44:43 AM INF Test  2/10: [RUN] status_test
TEST - 2019-11-26 11:44:43 - INFO - Launching test binary out/stm32f429i-disc1/obj/pw_status/status_test.elf
TEST - 2019-11-26 11:44:43 - INFO - Flashing firmware to device...
TEST - 2019-11-26 11:44:44 - INFO - Successfully flashed firmware to device!
TEST - 2019-11-26 11:44:44 - INFO - Resetting device...
TEST - 2019-11-26 11:44:44 - INFO - Successfully reset device!
TEST - 2019-11-26 11:44:44 - INFO - Test passed!
20191126 11:44:44 AM INF Test  2/10: [PASS] status_test

Change-Id: I916b3ea06a5a785a5d7f0f3653e96f8950037559
2019-11-26 22:02:57 +00:00
Keir Mierle
54f457f205 Rename pw_cmd to pw_cli
This renames pw_cmd to pw_cli, since our plan is for the cli module to
contain general command line interface related tooling, rather than just
the pw_cmd itself.

Change-Id: I1dc7185db25b89d725601ac5d47e0793ea907bf1
2019-11-25 22:16:02 +00:00
Alexei Frolov
3dbfcf04be
Make test runner script a pw command plugin
This change registers the test_runner.py script in pw_unit_test as a pw
plugin. To do this, pw_unit_test is defined also as a Python module with
a setup.py file. The script continues to work in standalone mode and in
the Ninja build for autorun targets.

Change-Id: Ida9c59a8a4563e794632921a3131192bc0568ee6
2019-11-25 11:10:28 -08:00
Alexei Frolov
8403f0a2db Update test runner to run tests from metadata
This change adds functionality to the test runner script to search a
directory tree for generated test metadata files, build up a graph of
test groups, and run a user-specified list of groups with all of their
dependencies.

Tests are run through an external runner executable provided on the
command line. The executable is called with the path to a unit test
binary file.

The old test runner functionality to run a single test directly from its
binary path is maintained, but now uses a runner executable. This is
configured in GN using the build variable "pw_automatic_test_runner",
which replaces the functionality of "pw_unit_test_create_run_targets".

Change-Id: Ic1ed959d87a71266408e1f26e0ae1bf906eebfb0
2019-11-22 17:58:51 +00:00
Alexei Frolov
917756d925
Add a stamp option to pw_python_script
GN requires all actions to have at least one output file. However, many
Python scripts are run to process data without generating a file. Such
scripts would previously have to specify a dummy output file and touch
it on completion.

This change adds this stamp functionality to the script-runner script.
The pw_python_script template accepts a boolean "stamp" argument. If
set, the runner will touch a dummy file after it runs its sub-command.

Change-Id: Iff0408ea0d93007418a1766f1eb7ed7b30ec6913
2019-11-12 15:07:43 -08:00
Alexei Frolov
d1f98fadeb Script-runner script and pw_python_script template
This change adds a pw_python_script GN template which defines an action
to run a Python script through a script-runner script. This runner is
responsible for resolving any GN paths to filesystem paths, and finding
output binaries for compiled targets. This allows writing Python scripts
which are ignorant of the GN build system and work only with filesystem
paths.

The unit test runner script is updated to use the new runner template.

Change-Id: I132bb620af2bb1e57e9278fac57b676f8ab5a415
2019-11-12 18:40:24 +00:00
Alexei Frolov
925fb8f510 Build and run unit tests through GN
This change adds a GN template for defining unit test executables.
The template, called pw_test, defines the executable and outputs a JSON
metadata file for the test.

A new build argument is added. This argument determines whether unit
test run targets are supported by the current build target. If this is
set, the pw_test template additionally creates a run target for its test
executable which invokes the executable through a script.

A basic test runner script is added to the pw_unit_test module. This
script currently only runs a single test executable directly.

The unit tests in the pw_preprocessor module are updated to use the
pw_test template.

Change-Id: I3cbde9c19440276dbab80dd2bab5fec87abe6d7e
2019-11-08 01:16:04 +00:00