aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/cpp
Commit message (Collapse)AuthorAge
...
* Bazel client, Windows: case-insensitive MSYS rootGravatar Laszlo Csomor2017-01-03
| | | | | | | | | | | | Make the MSYS root retrieval case-insensitive. While there, make the MSYS root resetable so we can test it. See https://github.com/bazelbuild/bazel/issues/2323 -- PiperOrigin-RevId: 143377137 MOS_MIGRATED_REVID=143377137
* Bazel client, Windows: fix MSYS root retrievalGravatar Laszlo Csomor2017-01-03
| | | | | | | | | | | | | | | | | | | | | The file_windows.cc:MsysRoot::Get() function was incorrectly assuming that bash.exe is usually under c:\tools\msys64\bin\bash.exe when in reality it's c:\tools\msys64\usr\bin\bash.exe, so we need to walk up one more directory. Unfortunately the test was assuming the same so the bug wasn't caught. The new code is a bit more foolproof in that it looks for an msys-looking final path segment and assumes that to be the msys root. Fixes https://github.com/bazelbuild/bazel/issues/2323 -- PiperOrigin-RevId: 143372193 MOS_MIGRATED_REVID=143372193
* Bazel client, Windows: implement ReadFileGravatar Laszlo Csomor2016-12-21
| | | | | | | | | | | | | | | | Implement blaze_util::ReadFile on top of the ::ReadFile Windows API function. Also implement blaze_util::AsWindowsPath so we can convert MSYS paths to Windows widechar paths. Add tests. See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 142659955 MOS_MIGRATED_REVID=142659955
* Bazel client, POSIX test: fix compilation errorGravatar Laszlo Csomor2016-12-21
| | | | | | -- PiperOrigin-RevId: 142654978 MOS_MIGRATED_REVID=142654978
* Bazel client: remove blaze_util::WhichGravatar Laszlo Csomor2016-12-21
| | | | | | | | | This is only used in blaze_util_linux so move the method there. -- PiperOrigin-RevId: 142652521 MOS_MIGRATED_REVID=142652521
* Bazel client; implement NormalizePathGravatar Laszlo Csomor2016-12-21
| | | | | | | | | | | | | | | | | | | | | | | | This method can normalize paths with "." and ".." and multiple "/" characters. E.g. normalize("../foo/./bar/../baz") = "foo/baz" This method enables us implementing PathExists on Windows. If the path to check is too long, we need to prefix it with "\\?\" for the Windows API functions to work, but then the path must be fully normalized and in Windows format. We already have functions to convert a path to Windows format but that doesn't normalize; with this function we can finally convert paths like "/c/foo/../bar" to L"\\?\c:\foo" and check if it exists. See https://github.com/bazelbuild/bazel/issues/2107 See https://github.com/bazelbuild/bazel/issues/2181 -- PiperOrigin-RevId: 142648194 MOS_MIGRATED_REVID=142648194
* Bazel client, Windows: implement AsWindowsPathGravatar Laszlo Csomor2016-12-20
| | | | | | | | | | | | | | | | | | | | This method converts MSYS paths to Windows path. It uses the BAZEL_SH envvar to obtain the MSYS root directory, to which all Unix paths (except for mounts) are relative. We cannot handle mounts because we don't want to read /etc/mtab every time there's a file operation so we simply apply a heuristic similar to https://github.com/bazelbuild/bazel/blob/cd4cc09fa6ef96380a3d0888f825dfd1dbada651/src/main/java/com/google/devtools/build/lib/vfs/WindowsFileSystem.java#L52-L63 Also clean up the #ifdefs surrounding SyncFile. See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 142531986 MOS_MIGRATED_REVID=142531986
* Bazel client: generalize path handlingGravatar Laszlo Csomor2016-12-19
| | | | | | | | | | | | | | Use/implement utility methods to join paths, check if they are the root directory or are absolute, etc. Doing so (instead of say checking if a path starts with "/") allows for correct behavior on Windows. See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 142446027 MOS_MIGRATED_REVID=142446027
* Bazel client: SplitPath works with Windows pathsGravatar Laszlo Csomor2016-12-19
| | | | | | | | | | | This allows correct behavior of Dirname and Basename on Windows. See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 142441234 MOS_MIGRATED_REVID=142441234
* Fix test flakiness.Gravatar Laszlo Csomor2016-12-19
| | | | | | | | | | | | | | | | | | | | | | | In the Bazel client's file_test, when testing multi-threaded pipe access, wait for all data to be written into the pipe. Pipes are not synchonization primitives in that read(2) returns immediately, reading as much data as it can, and won't block if it cannot read as much as requested. (This is even tested by the last ASSERT_EQ, trying to read 40 bytes.) This is however also true for the second ASSERT_EQ that attempts to read 5 bytes. The Send on the writer_thread is racing with the Receive on the main thread (as it should), and sometimes the main thread wins, resulting in fewer bytes received than previously expected. -- PiperOrigin-RevId: 142429243 MOS_MIGRATED_REVID=142429243
* Bazel client, Windows: implement pipe handlingGravatar Laszlo Csomor2016-12-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Create WindowsPipe which implements IPipe, and is a Windows-native implementation of pipe handling. It wraps the ::CreatePipe, ::WriteFile, and ::ReadFile API functions. Start using WindowsPipe on MSYS. Also move everything from file_test.cc into file_posix_test.cc, because these test methods heavily depend on POSIX and they test file_posix's functionality anyway. Also add tests for pipes: this will use the platform-specific implementation of IPipe. file_test.cc is now platform-independent, and we can test it with --cpu=x64_windows_msvc (and it passes!). See https://github.com/bazelbuild/bazel/issues/2107 Might also fix: https://github.com/bazelbuild/bazel/issues/2182 https://github.com/bazelbuild/bazel/issues/2248 -- PiperOrigin-RevId: 142240377 MOS_MIGRATED_REVID=142240377
* Bazel client: implement Cstring-Wstring conversionGravatar Laszlo Csomor2016-12-14
| | | | | | | | | | | | Implement conversion methods between char strings and wchar_t strings. This is necessary to use widechar Windows functions. See https://github.com/bazelbuild/bazel/issues/2181 -- PiperOrigin-RevId: 142009930 MOS_MIGRATED_REVID=142009930
* Description redacted.Gravatar Julio Merino2016-12-09
| | | | | | -- PiperOrigin-RevId: 141483567 MOS_MIGRATED_REVID=141483567
* Add SearchUnaryOptions and SearchNullaryOptions to improve the parsingGravatar Luis Fernando Pino Duque2016-12-09
| | | | | | | | | | | | of the startup options. This allows us to do the following: - Avoid using the product name when reporting startup option parsing errors. - Passing --bazelrc as a command argument throws an error (fix for issue #1659). -- PiperOrigin-RevId: 141445030 MOS_MIGRATED_REVID=141445030
* move MakeDirectories() into file_platform.hGravatar Thiago Farina2016-12-07
| | | | | | | | | | | | | | This way we can remove the dependency on blaze_util (which is Bazel's client specific) from singlejar. This work was made possible by commit 49970e0136d0: ("Bazel client: platform-specific {Read,Write}File"). -- Change-Id: I6e95fb9119a271e4d48cbe2eefc1d5354ee188aa Reviewed-on: https://cr.bazel.build/7650 PiperOrigin-RevId: 141294165 MOS_MIGRATED_REVID=141294165
* Bazel client: platform-specific {Read,Write}FileGravatar Laszlo Csomor2016-11-28
| | | | | | | | | | | | | | | | Move blaze::ReadFile and blaze::WriteFile to file.h and file_platform.h (thus into the blaze_util namespace), and update references. This allows us to implement these methods in a platform-specific way. Also move UnlinkPath. See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140328273
* Bazel client: mock out read/write callsGravatar Laszlo Csomor2016-11-28
| | | | | | | | | | | | | | | | | | | | | | | | | Make blaze::ReadFileDescriptor(int fd, ...) and blaze::WriteFile(int fd, ...) platform-independent by mocking out the read(2) and write(2) calls. Also rename ReadFileDescriptor to ReadFrom and introduce a new WriteTo method that encapsulates WriteFile's prior logic. In particular these functions now take a read_func/write_func function argument instead of a file descriptor, so the read(2)/write(2) calls can be mocked out. This allows us to use these functions on Windows too, where read(2)/write(2) are not implemented, and we can inject a different read_func/write_func. See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140195973
* Adds logging functionality to the bazel client, which will be activated in a ↵Gravatar Chloe Calvarin2016-11-23
| | | | | | | later change. -- MOS_MIGRATED_REVID=139951184
* Bazel client: reduce dependency on POSIX APIGravatar Laszlo Csomor2016-11-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can now compile blaze_util_windows.cc with MSVC, yay! (when building //src:bazel --cpu=x64_windows_msvc -k). There are a lot of #ifdef's and TODOs so this is a modest victory for now. In this change: - change blaze::MakeDirectories to return bool instead of int, since that's how it was used anyway, and to expect the permission mask as unsigned int instead of mode_t, since the former is good enough and compatible with mode_t on POSIX while mode_t is not defined on Windows - move blaze::MakeDirectories into blaze_util_<platform> - implement envvar-handling in blaze_util_<platform> and use it everywhere See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=139887503
* Provide a SplitCommandLine method in the option processorGravatar Luis Fernando Pino Duque2016-11-21
| | | | | | | | | | | | | that takes a given command line args and splits it into the corresponding {binary, startup_args, command, command_args}. The purpose of this function is to help split the responsibilities of the ParseOptions function by processing the startup options independently (i.e. rc files detection and processing) from the command options. This will be combined with ParseOptions in a subsequent CL. -- MOS_MIGRATED_REVID=139773786
* Bazel client: implement directory tree walkingGravatar Laszlo Csomor2016-11-16
| | | | | | | | | | | | | | | | | | | | | | This change: - merges the //src/{main,test}/cpp:file and //src/{main,test}/cpp:file_platform libraries because "file" and "file_platform" need each other and this makes logical sense anyway - implements a function in file_<platform> to run a custom function on every child of a directory - implements a function in file.cc to recursively traverse a directory tree, based on the previosly mentioned function - removes the corresponding logic from the Bazel client to make it more portable -- MOS_MIGRATED_REVID=139309562
* Really mark //src/main/cpp/util:file_platform_test as manualGravatar Klaus Aehlig2016-11-11
| | | | | | | | | | ...as opposed to //src/test/cpp:blaze_util_test which works fine. -- Change-Id: I1e629e6f8eda47cd7eac11511d54ee23f7122848 Reviewed-on: https://bazel-review.googlesource.com/#/c/7335 MOS_MIGRATED_REVID=138871238
* Mark //src/test/cpp/util:file_platform_test as manualGravatar Klaus Aehlig2016-11-11
| | | | | | | | | ...as it fails to compile. -- Change-Id: I9040f953235fd71b1d5cfc2bb3dbcba9182ad085 Reviewed-on: https://bazel-review.googlesource.com/#/c/7334 MOS_MIGRATED_REVID=138865280
* Bazel client: wrap some POSIX functionsGravatar Laszlo Csomor2016-11-10
| | | | | | | | | | | | | | This change: - starts using blaze_util::CanAccess and blaze_util::PathExists instead of access(2) - implements and starts using blaze_util::GetCwd instead of getcwd(2) - implements and starts using blaze_util::ChangeDirectory instead of chdir(2) - adds tests for the new wrapper methods -- MOS_MIGRATED_REVID=138750297
* Rollback of commit b6301a5f7628d5a7e11abc6c1115918d42c6fba8.Gravatar Luis Fernando Pino Duque2016-10-28
| | | | | | | | | | | | | | *** Reason for rollback *** Breaks blaze_util_test for Bazel https://github.com/bazelbuild/bazel/issues/1999 *** Original change description *** Uncomment lines inside blaze_util_tests since the tests are now passing. -- MOS_MIGRATED_REVID=137516264
* Add the IsNullary(arg) and IsUnary(arg, next_arg) functionsGravatar Luis Fernando Pino Duque2016-10-28
| | | | | | | to detect whether arg is a valid startup option. -- MOS_MIGRATED_REVID=137512954
* Add missing parameter to open(path, flags) call in CreateEmptyFile in ↵Gravatar Luis Fernando Pino Duque2016-10-27
| | | | | | | blaze_util_test. According to the man page of open, when O_CREAT is specified in flags then an extra parameter (t_mode mode) must be present too. -- MOS_MIGRATED_REVID=137314830
* Uncomment lines inside blaze_util_tests since the tests are nowGravatar Luis Fernando Pino Duque2016-10-26
| | | | | | | passing. -- MOS_MIGRATED_REVID=137196103
* cpp: header hygienizationGravatar Thiago Farina2016-10-18
| | | | | | | | | | | * remove "using std::" declarations from header files * add missing "std::" to some string declarations at some header files * add "using std::string;" to some source files where necessary -- Change-Id: Ib64f62b5add499d6171fa922227194ac992fa542 Reviewed-on: https://bazel-review.googlesource.com/#/c/6630/ MOS_MIGRATED_REVID=136355671
* Tests: //src/test/cpp/util:* now pass with MSVCGravatar Laszlo Csomor2016-10-05
| | | | | -- MOS_MIGRATED_REVID=135208653
* Bake in the product name into the StartupOptions classes.Gravatar Julio Merino2016-09-15
| | | | | | | | | | Now that we have gotten a StartupOptions class for each of the products we support, we can bake in the product name in each instance instead of passing it to the constructor. Helps with encapsulation and simplifies various instantiations of these classes. -- MOS_MIGRATED_REVID=133255854
* Roll-forward of the startup options refactoring.Gravatar Julio Merino2016-09-15
| | | | | | | | | | | | | | | This CL is a verbatim reproduction of the following CLs, modulo adjustments to cope with changes at HEAD: * commit 4a45d92130a6b1306a3840d006df165b8040a6cf: Use inheritance to support site-specific options. * commit dfb2c73eda3d2dd8787ea9b2d0a03b49dfa2acc5: Inject the product name via the per-product main.cc files. * unknown commit: Remove the internal/external startup_options duality. The cause that triggered the rollbacks was fixed separately in commit 69a8d7205287bedf3a6140ec9327e2fad1758c22 as prepartory work for this roll-forward, so things should work now. -- MOS_MIGRATED_REVID=133139218
* Move the GetOutputRoot function to the WorkspaceLayout module.Gravatar Julio Merino2016-09-14
| | | | | | | | | | | | | | | | | | | | | | The result value of GetOutputRoot does not depend on the startup options: it only depends on the environment and/or the hardcoded values for Bazel and Blaze. Therefore, put it in the WorkspaceLayout module just as we did for all other similar functions. The fact that GetOutputRoot was part of BlazeStartupOptions was the root cause behind the rollback of commit 4a45d92130a6b1306a3840d006df165b8040a6cf: in particular, that CL silently added a virtual call to the GetOutputRoot method from the constructor of the superclass, and this invokes undefined behavior because the class has not yet been fully constructed. This caused Blaze to have incorrect values for the output_root. By moving the function out, we'll be able to roll that CL forward as it originally was. As part of this change, add unit tests for the value of output_root under various scenarios. These would have caught the discrepancy introduced by that CL. -- MOS_MIGRATED_REVID=133056251
* Add all the sources to //:srcs filegroup and add a check to detectGravatar Damien Martin-Guillerez2016-07-01
| | | | | | | | | | | missing file to it. We need to activate this check on presubmits -- Change-Id: Ia95e92d3816ce92bb69bc0e2cf56e9c60b68d970 Reviewed-on: https://bazel-review.googlesource.com/#/c/3949/ MOS_MIGRATED_REVID=126404792
* Factor out various ways to execute subprocesses into separate functions.Gravatar Lukacs Berki2016-04-25
| | | | | | | This is so that they can be implemented properly for Windows. For now, though, they are left in blaze_util.cc since the Windows implementations aren't there yet. -- MOS_MIGRATED_REVID=120709884
* Make the integration tests pass with gRPC client/server comms.Gravatar Lukacs Berki2016-04-21
| | | | | | | | | | | In particular: - Make a SIGINT to the server interrupt every command - Parse negative numbers on the command line correctly (std::stoi throws an exception, and I'd rather not start using C++ exceptions) - Use "bytes" for command line arguments instead of "string" in the client/server proto . This is more principled, although we pretend all arguments are strings all over the place and it works for "blaze run" mostly by accident. -- MOS_MIGRATED_REVID=120434432
* add some missing errno.h and string.h includesGravatar Mostyn Bramley-Moore2015-11-11
| | | | | | -- Reviewed-on: https://github.com/bazelbuild/bazel/pull/571 MOS_MIGRATED_REVID=107471259
* Set sharding and tmpdir environment variables for googletestGravatar Brian Silverman2015-10-22
| | | | | | | | | | The patch for googletest to prefer GTEST_TMP_DIR is google/googletest#619 and should be merged soon. -- Change-Id: If48220e8e1e4e78a8768aeb14b5b58e4f246c8c3 Reviewed-on: https://bazel-review.googlesource.com/#/c/2170/ MOS_MIGRATED_REVID=106043714
* Rationalize copyright headersGravatar Damien Martin-Guillerez2015-09-25
| | | | | | | | | | | The headers were modified with `find . -type f -exec 'sed' '-Ei' 's|Copyright 201([45]) Google|Copyright 201\1 The Bazel Authors|' '{}' ';'` And manual edit for not Google owned copyright. Because of the nature of ijar, I did not modified the header of file owned by Alan Donovan. The list of authors were extracted from the git log. It is missing older Google contributors that can be added on-demand. -- MOS_MIGRATED_REVID=103938715
* Some minor updates to the BUILD files.Gravatar Ulf Adams2015-09-15
| | | | | -- MOS_MIGRATED_REVID=103087492
* Replace pipe2() by pipe() and fnctl()Gravatar Damien Martin-Guillerez2015-09-08
| | | | | | | pipe2() does not exists on Darwin. -- MOS_MIGRATED_REVID=102544058
* Fix the blaze_util_test to compile and pass.Gravatar Ulf Adams2015-09-08
| | | | | | | | I had to comment out a couple of tests, I don't know why they're not passing right now. -- MOS_MIGRATED_REVID=102535967
* Move blaze_util_test.cc into the open source tree.Gravatar Ulf Adams2015-09-08
| | | | | -- MOS_MIGRATED_REVID=102487385
* Fixed Bazel test target //src/test/cpp/util:strings_test by adding a missing ↵Gravatar Florian Weikert2015-08-10
| | | | | | | "using" statement. -- MOS_MIGRATED_REVID=100262453
* Externalize file_test and strings_test, and fix up the BUILD files.Gravatar Ulf Adams2015-08-10
-- MOS_MIGRATED_REVID=100109450