diff options
author | Laszlo Csomor <laszlocsomor@google.com> | 2017-01-18 13:30:35 +0000 |
---|---|---|
committer | Vladimir Moskva <vladmos@google.com> | 2017-01-18 16:02:06 +0000 |
commit | 73e971cc7f90896feed6c83d56b4903e7dfe1198 (patch) | |
tree | 840807d5e182e98e93a5f675cd6b7bbb9b1058d7 /src/BUILD | |
parent | 63c9af49bbf3ca7f0d8619a9636bce2b8b70b5c6 (diff) |
Windows, JNI: add tests for windows_util
Add tests for the AsExecutablePathForCreateProcess
method, since its logic is pretty complex.
Unfortunately testing it also requires complex
logic, as we need to test what exactly happens
when the input path is shorter than MAX_PATH or
when it's longer than it. To test that reliably,
we need a base path that we know will not get
shortened. Creating that base path under the temp
directory is a nightmare, we need to:
(1) retrieve the temp dir, shorten it so we know
that it won't be shortened further
(2) keep creating subdirectories that have a short
name so they also won't get shortened, but keep
the entire path below MAX_PATH while leaving
enough space for a file name in the end
(3) append a file name such that the path is just
below MAX_PATH, or is exactly that long, or is
longer than it. Because of steps (1) and (2) we
can be sure that no other component in the path
will get shortened, so we can test exactly what's
going on with the shortener logic and its error
handling. But oh boy is it complicated.
Side note, we need to use the Widechar WinAPI
functions to create/delete the directories and
files, because the POSIX API on Windows appears to
be backed by the ASCII API functions, so
attempting to `mkdir` with a path longer than
CreateDirectoryA's limit is going to fail.
But on the positive side, adding tests caught two
bugs in the method, so we have that going for us
which is nice.
See https://github.com/bazelbuild/bazel/issues/2107
See https://github.com/bazelbuild/bazel/issues/2181
--
PiperOrigin-RevId: 144823029
MOS_MIGRATED_REVID=144823029
Diffstat (limited to 'src/BUILD')
-rw-r--r-- | src/BUILD | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -313,6 +313,7 @@ filegroup( "//src/objc_tools/plmerge:srcs", "//src/objc_tools/xcodegen:srcs", "//src/test/cpp:srcs", + "//src/test/native:srcs", "//src/test/java/com/google/devtools/build/android:srcs", "//src/test/java/com/google/devtools/build/docgen:srcs", "//src/test/java/com/google/devtools/build/lib:srcs", |