0
Commit Graph

13 Commits

Author SHA1 Message Date
Andrew Grieve
c2122d27d5 Make autotest.py recognize chrome_public_test_vr_apk
The suffix is _test_vr_apk rather than _test_apk, so it wasn't being
identified as a test.

Bug: None
Change-Id: Idb4e8eb7bb4efd9625940d3ea28c664e4f98c50c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2687655
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#852661}
2021-02-10 16:22:29 +00:00
Mario Bianucci
6b5450075b Allow autotest to collect tests that don't include gtest files
Autotest checks for gtest files to better determine if a give file is
actually a test file or not. However, because many files don't actually
include what they use, many test files don't directly include gtest.h,
gmock.h, or a test_utils.h file. Instead, they may include those via
something like sim_test.h, resulting in the script ignoring those files
right now.

This change improves that by still looking for files that include a
gtest file, but until it has found at least one file that does, it
will also collect files that match the test file name regex and do not
match the gtest include regex. Then, if no files are found with the
gtest includes, it will move forward under the assumption that the
file it found without the gtest include was the correct test file.

It will still prefer files with gtest includes, but has a fallback in
case none exist, providing a best effort chance at building and
running the tests.

Also includes a small improvement to outputting the file names that
it finds after a recursive file search.

Change-Id: Ia56792426b55cb17a43ffe2545b4deefb5dba0dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2568710
Commit-Queue: Mario Bianucci <mabian@microsoft.com>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832607}
2020-12-02 01:33:39 +00:00
Michael Thiessen
a8a82f5c65 Fix autotest dry run
Fixes autotest dry run to print both the build and test run command,
instead of just the build command.

Change-Id: I8bbccacb2e8360f3a9066c4a02de5867d79542b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2565590
Auto-Submit: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#831895}
2020-11-30 18:05:32 +00:00
Mario Bianucci
ebea79d708 Improvements to autotest.py
This CL includes several improvements to autotest.py:
-Slightly expand the GTest regex.
  -Previously, it missed some tests due to them not explicitly including
    gtest via #include "...gtest.h". Variations included <...gtest.h>,
    gmock.h, or via *test_utils.h. Expand the regex to include these
    cases.
  -In my (limited) testing I didn't see any large regressions in terms
    of number of files added via the expanded regex, but its possible
    there is something I missed.
-Add utf-8 encoding when opening a file to read.
  -This avoids errors when opening files with non-English characters.
-Debugging lines to output all files that matched the regex.
-Added sys.executable to beginning of call to make-gtest-filter.py.
  -This enables it to work on Windows, which requires 'python3' before
    calling a python script.

Change-Id: Ic9e67658b7298867d997ba4cc396320bf5d61c8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2517944
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Mario Bianucci <mabian@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#824031}
2020-11-04 17:19:00 +00:00
Andrew Grieve
a5193d3a54 autotest.py: Use autoninja from PATH. Make -C optional
Use autoninja from PATH so that it matches the version used when
building explicitly (allows for devs that are using a custom-built
version of ninja).

Allow omitting -C when script is run from within the output directory.
This matches ninja's behavior.

Bug: None
Change-Id: I55763f178e2cf85892efbb4397a7ec81ed054aa5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419608
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808875}
2020-09-21 14:58:34 +00:00
Michael Thiessen
7bbda48e1f Make autotest java test filter more robust
Fix autotest so autotest.py -C <dir> /CurrentPageVerifierTest.java won't
run tests for other classes like WebApkCurrentPageVerifierTest

Change-Id: I0370b507ac21009676d9e27c109b90d7223b7ab9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419267
Auto-Submit: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808645}
2020-09-19 02:07:34 +00:00
Dan Harrington
aa2c7ba1e9 A few autotest improvements
* > autotest ... base/strings/strcat.cc
  will now run tests for base/strings/strcat_unittest.cc

* > autotest ... strcat
  no longer complains "strcat" is ambiguous, since strcat_unittest.cc is
  the only matching test file.

* Fixed rare case where caching could use the wrong
  target.

Change-Id: Id028b8d5477687bef02b6cd94688f74839d08964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2407857
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Dan H <harringtond@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807479}
2020-09-16 15:34:24 +00:00
Dan Harrington
27d104dac2 Improvements to autotest.py
- Use make-gtest-filter.py to build a gtest filter automatically.
- Allow testing a full directory.
- --run-all: allow testing multiple targets in one run, instead of
  asking the user to pick.
- Speed it up if a file path is specified, by skipping the file
  search.
- Cache gn refs output, to make follow-up runs faster.
- Add --line option, to run a test at specific line number.
- Change call to ninja build so that output is streamed
- Switch to printing errors end then exiting for non-exceptional errors.
  This makes user errors more readable.

Change-Id: Ib3660123f5a7fe5c3ef3369d360c3ea3218d233a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391209
Commit-Queue: Dan H <harringtond@chromium.org>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804987}
2020-09-08 18:30:14 +00:00
Jesse McKenna
83b6ac1b8a Make autotest.py support forward slash on Windows
Currently, autotest.py doesn't support the forward slash '/' as a path
separator on Windows. For example:

Succeeds:
python3 tools/autotest.py -C out/bug base\at_exit_unittest
--gtest_filter=*Exit*

Fails:
python3 tools/autotest.py -C out/bug base/at_exit_unittest
--gtest_filter=*Exit*

This is because RecursiveMatchFilename() considers a file a match with
the requested filename if the requested filename is a substring of the
file's full path. On Windows, file paths as returned by os.scandir()
use '\\' as a path separator, so a path using '/' will never match
(e.g. 'base/at_exit_unittest' is not a substring of
'C:\\src\\chromium\\src\\base\\at_exit_unittest.cc').

With this change, either type of path separator works on Windows.

Change-Id: Ic21eff291d86e7ca994faeda807f6aeaff737562
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2181744
Commit-Queue: Jesse McKenna <jessemckenna@google.com>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#766500}
2020-05-07 18:25:38 +00:00
Michael Thiessen
0264afc6c7 Ignore vim swap files in autotest.py
Change-Id: Iac30106a597ade4a6a7826bf5ed9890c94a1514f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135423
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756398}
2020-04-03 20:31:34 +00:00
K. Moon
01548667da Fix autotest.py's platform check on macOS
tools/autotest.py currently uses `"win" in sys.platform` to detect if
the current platform is Windows. macOS uses "darwin" as the platform, so
this check erroneously detects macOS as Windows.

According to the documentation for sys.platform, the platform value
should be matched against sys.platform as a prefix:
https://docs.python.org/3/library/sys.html#sys.platform

This change tightens the check to only detect platforms starting with
"win32" as Windows.

R=mthiesse

Change-Id: Ic46cbc3b28c250d6557a58f583d5a9ba03df5b6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134964
Auto-Submit: K Moon <kmoon@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756079}
2020-04-03 00:14:25 +00:00
Michael Thiessen
f46171eb76 Support //chrome/test:unit_tests in autotest.py
Bug: 1066521
Change-Id: Ib591b5ee471f4bc55a8fbbec2a1cd0b4762e1b60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2129990
Reviewed-by: Brandon Wylie <wylieb@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754994}
2020-03-31 17:29:38 +00:00
Michael Thiessen
09c0e1d0b7 Introduce script to build and run a test file by name.
Uses gn refs to find the test target containing the file, then builds
and runs the suite. For java test files the filter can be automatically
generated, but for c++ it isn't as straightforward so I've made the
filter mandatory.

./tools/autotest.py -C out/Desktop image_decoder_browsertest.cc --gtest_filter="ImageDecoder"
./tools/autotest.py -C out/Android UrlUtilitiesUnitTest --fast-local-dev -v

Examples: 
Change-Id: I1840ef3634e4a011f871acd973d5f8bb5038c3a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2101542
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752515}
2020-03-23 18:44:50 +00:00