aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java
Commit message (Collapse)AuthorAge
* Support basic test functionality in ActionFS.Gravatar felly2018-06-08
| | | | | | | | | ActionFS now allows output files to be created that do not correspond to known Artifacts. Note that tests exercise a greater gamut of filesystem functionality (deleting files, deleting directory trees, moving files, etc.) RELNOTES: None PiperOrigin-RevId: 199809069
* Changing SymlinkTreeStrategy not to use spawns.Gravatar Googler2018-05-18
| | | | | RELNOTES: An internal action for symlinking runfiles will use Command instead of a Spawns. This should have no functional chages; the only user visible consequence should be that the internal action is no longer be included in statistics when calculating processes count. PiperOrigin-RevId: 197131917
* SpawnAction.setShellCommand: expect shell pathGravatar laszlocsomor2018-04-23
| | | | | | | | | | | | | | | | | | | | | | | SpawnAction.setShellCommand(String) now expects the shell interpreter's path as an argument. This change enables two things: - rules can report an error if the shell is missing - SpawnAction no longer has to know about a default shell The new ShToolchain class will later also be responsible for retrieving the active shell toolchain (added in https://github.com/bazelbuild/bazel/commit/81ed3add408adb20bddbc3ba1818c65806738dc5). This change brings Bazel closer to not depend on the shell unless it has to (e.g. to run shell scripts). See https://github.com/bazelbuild/bazel/issues/4319 RELNOTES: none PiperOrigin-RevId: 193885943
* Move test_timeout to BuildConfiguration and TargetCompleteEvent.Gravatar Googler2018-04-17
| | | | | | | | - Move test_timeout to BuildConfiguration. - Add test_timeout_seconds field to BEP TargetCompleteEvent. - Deprecate test_timeout field in ExecutionInfo. Data is still written to deprecated field to allow consumer transition. PiperOrigin-RevId: 193192636
* Move shell executable to its own configuration fragment.Gravatar lberki2018-04-06
| | | | | RELNOTES: None. PiperOrigin-RevId: 191861074
* Change profiling to only accept strings for its "description" argument. ↵Gravatar janakr2018-04-01
| | | | | | Profiling can hold onto objects for the duration of the build, and some of those objects may be temporary that should not be persisted. In particular, UnixGlob and its inner classes should not outlive loading and analysis. For the most part, care was taken in this CL to only use strings that required no additional construction, mainly to minimize garbage (retaining references to newly created strings is not as great a concern since only the strings corresponding to the slowest K tasks are retained, for some relatively small values of K). Action descriptions for actually executing actions are eagerly expanded because that work is minimal compared to the work of actually executing an action. PiperOrigin-RevId: 191251488
* Begins cleanup to allow ActionFS to be injected into all action executions.Gravatar shahan2018-03-15
| | | | PiperOrigin-RevId: 189244665
* Update --flaky_test_attempts to also take a repeatable argument of the formGravatar jcater2018-02-20
| | | | | | | | | regex@attempts, similarly to --runs_per_test. Also re-arrange some option converters to be closer to their options. RELNOTES: flaky_test_attempts supports the regex@attempts syntax, like runs_per_test. PiperOrigin-RevId: 186358437
* Move BinTools to lib.execGravatar ulfjack2018-02-15
| | | | | | | It's never used during analysis, it shouldn't be used during analysis, so let's not make it available during analysis. PiperOrigin-RevId: 185808384
* Remove a few unused fields.Gravatar lberki2018-02-09
| | | | | RELNOTES: None. PiperOrigin-RevId: 185138928
* Remove hard-wired basenames for the test setup and the coverage collection ↵Gravatar lberki2018-02-09
| | | | | | | | | script. Accomplished by creating an explicit attribute for both of them on test actions. RELNOTES: None. PiperOrigin-RevId: 185132460
* Give a reasonable environment for tests run by "blaze run --direct_run".Gravatar lberki2018-02-08
| | | | | | | | | | | | It's not entirely correct, but almost. The code in RunCommand becomes somewhat more confusing. Cleanup change incoming. Fixes #2815. RELNOTES[INC]: "blaze run --direct_run" with tests now gives the test an approximation of the official test environment. PiperOrigin-RevId: 184992651
* Rework implementation of --nobuild_runfile_manifests.Gravatar Benjamin Peterson2018-01-03
| | | | | | | | | | | | | When --nobuild_runfile_manifests is passed, don't create runfiles input or output manifests at all. This seems better than creating fake manifest artifacts that are actually a middleman. Fail fast for local tests and the run command when --nobuild_runfiles_manifests is passed. (These cases were failing with obscure errors before under --nobuild_runfile_manifests-I just improved the messaging. See https://github.com/bazelbuild/bazel/issues/4177.) Change-Id: I351d26f746ecbe47016b58e4662768a5b6a72ff2 PiperOrigin-RevId: 180659571
* Clean up ExecutionRequirementsGravatar ulfjack2017-11-29
| | | | | | | | | | | | | | | | | | | - remove BaseSpawn.Local; instead, all callers pass in the full set of execution requirements they want to set - disable caching and sandboxing for the symlink tree action - it does not declare outputs, so it can't be cached or sandboxed (fixes #4041) - centralize the existing execution requirements in the ExecutionRequirements class - centralize checking for execution requirements in the Spawn class (it's possible that we may need a more decentralized, extensible design in the future, but for now having them in a single place is simple and effective) - update the documentation - forward the relevant tags to execution requirements in TargetUtils (progress on #3960) - this also contributes to #4153 PiperOrigin-RevId: 177288598
* Return SpawnResults using a List instead of a Set.Gravatar ruperts2017-11-21
| | | | | | | | | Currently we don't care about the list order of SpawnResults. However, we may care about the list order later. Also, if the equals() method for SpawnResults is ever changed then it may be problematic to return SpawnResults in a Set. Aside: ActionResults use SpawnResults to calculate cumulative execution times for Actions, and may provide other metrics in future. RELNOTES: None. PiperOrigin-RevId: 176579460
* More SpawnResult-related plumbing changes to Actions, Strategies, ↵Gravatar ruperts2017-10-07
| | | | | | | | | ActionContexts, etc., so that SpawnResult metadata is returned upwards. Note that the TODOs mostly refer to changes that will appear in a subsequent CL (a CL to return SpawnResults, contained in ActionResults, from Actions/AbstractActions). I split off the remaining SpawnResult-related changes into this CL and kept the ActionResult-related changes separate. RELNOTES: None. PiperOrigin-RevId: 171355611
* Fix more linter errorsGravatar ruperts2017-10-06
| | | | | RELNOTES: None. PiperOrigin-RevId: 170955877
* In terse test_summary, skip no-status testsGravatar Klaus Aehlig2017-08-30
| | | | | | | | | If there is a build failure, don't clobber the terse test summary by naming all the (usually many) tests that were skipped due to this failure. Change-Id: I6daae3efb1594c2b1018f87a50cf63949a34535b PiperOrigin-RevId: 166983264
* Allow CommandLine expansion to throw an exception.Gravatar tomlu2017-08-24
| | | | | | | | | | | | | | | | | | | This paves the way for Skylark-side compact command lines that can fail during expansion. In general, expansion happens in these scenarios: * Action execution expands the command line to execute it. This is fine since we are well equipped already to handle failing actions. * In the analysis phase we expand command lines to investigate whether we need a params file. This could be moved to the execution phase, which would have the benefit of getting params files out of the action graph and saving memory. * Key computation expands the command line. This could be fixed by allowing command lines to compute their own keys (which wouldn't try to expand the command line). This could have the benefit of being more efficient. * Extra actions expand the command line to construct the extra action proto. This could maybe be deferred to the execution phase (writing the extra action), which would also be more memory efficient. For failed key computations, we return a singleton "error" key. This means multiple actions that will fail will map to the same key. These actions will necessarily fail if executed, so we should not need to worry about these ending up in the action cache. If we do manage to make the command line compute its own keys then this will become moot in the future. RELNOTES: None PiperOrigin-RevId: 166266385
* Move core test classes to lib.analysis.testGravatar ulfjack2017-08-11
| | | | | | | | These are depended upon by analysis code, so need to live in the same library as lib.analysis. Moving them here makes it possible to split the build-base library into separate libraries for analysis, execution, and rules. PiperOrigin-RevId: 164847161
* Use java.time.Duration for timeoutsGravatar ulfjack2017-08-09
| | | | PiperOrigin-RevId: 164577062
* Slight refactor of helper methods in TestStrategy.Gravatar nharmata2017-07-31
| | | | | RELNOTES: None PiperOrigin-RevId: 163471182
* Rewrite the Executor/ActionExecutionContext splitGravatar ulfjack2017-06-19
| | | | | | | Move everything to ActionExecutionContext, and drop Executor whereever possible. This clarifies the API, makes it simpler to test, and simplifies the code. PiperOrigin-RevId: 159414816
* Rewrite StandaloneSpawnStrategy to use LocalSpawnRunnerGravatar ulfjack2017-06-19
| | | | PiperOrigin-RevId: 159221067
* Track the test environment in Skyframe, like the action environmentGravatar ulfjack2017-06-09
| | | | | | | | Instead of passing a client env into the test strategies, use the same mechansim as --action_env, by depending on the right set of Skyframe nodes that correspond to client env entries. PiperOrigin-RevId: 158401670
* Automated g4 rollback of commit e2edf2e141a09c025a958d580c7cac7b57c70d83.Gravatar Googler2017-05-26
| | | | | | | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Rollforward with fix. *** Original change description *** Automated g4 rollback of commit c78c947e6a8cbb323304f872a3dcabb989a3d76b. *** Reason for rollback *** Breaks android targets in the nightly - see [] *** Original change description *** Do not retain transitive data in AndroidLocalTestBase... *** ROLLBACK_OF=156745610 RELNOTES: None PiperOrigin-RevId: 157028029
* Automated g4 rollback of commit c78c947e6a8cbb323304f872a3dcabb989a3d76b.Gravatar cpeyser2017-05-23
| | | | | | | | | | | | | | *** Reason for rollback *** Breaks android targets in the nightly - see [] *** Original change description *** Do not retain transitive data in AndroidLocalTestBase. The argument strings and artifacts were both transitive and flattened, causing O(N^2) memory consumption. PiperOrigin-RevId: 156745610
* Do not retain transitive data in AndroidLocalTestBase.Gravatar Googler2017-05-15
| | | | | | The argument strings and artifacts were both transitive and flattened, causing O(N^2) memory consumption. PiperOrigin-RevId: 156083738
* Make the test tmp directory name deterministicGravatar ulfjack2017-04-24
| | | | | | Fixes #2853. PiperOrigin-RevId: 153730500
* Refactor all ctor callsites of PathFragment to instead call a static ↵Gravatar nharmata2017-04-05
| | | | | | | | | | | | 'create' method. This paves the way for changing PathFragment to e.g. an abstract class with multiple subclasses. This way we can split out the windows-specific stuff into one of these concrete classes, making the code more readable and also saving memory (since the shallow heap size of the NonWindowsPathFragment subclass will hopefully be smaller than that of the current PathFragment). This also lets us pursue gc churn optimizations. We can now do interning in PathFragment#create and can also get rid of unnecessary intermediate PathFragment allocations. RELNOTES: None PiperOrigin-RevId: 152145768
* Partial rollback of commit dd142c93fd4939aaec30726f275644ca9446fea2.Gravatar Philipp Wollermann2017-03-22
| | | | | | | | Should fix #2721. -- PiperOrigin-RevId: 150866145 MOS_MIGRATED_REVID=150866145
* windows: Improve env var handling of shell integration tests.Gravatar Philipp Wollermann2017-03-20
| | | | | | | | | | | | | | | | | | | | | | Use a unique TEST_TMPDIR for each running test on Windows, too. The old behavior caused shell tests to share the same TEST_TMPDIR, which caused conflicts when multiple tests were run in parallel. Set Bazel's TEST_TMPDIR root on Windows to c:/temp by default in TestStrategy. This avoids tripping the 260-character limit for paths. We still have to keep the override in testenv.sh for the time being, because Bazel's tests are often run with the latest released Bazel and thus we have to wait for a new Bazel release before we can remove the TEST_TMPDIR override from testenv.sh. Once that is done, the flag --test_tmpdir should also magically start working on Windows. Move the Python detection logic out of bazel_windows_example_test.sh into testenv.sh. This is better than copying that code into every new test's set_up method. -- PiperOrigin-RevId: 150433265 MOS_MIGRATED_REVID=150433265
* StandaloneTestStrategy sets the full list of outputs on the test spawnGravatar Ulf Adams2017-03-07
| | | | | | | | | | | | | | | | | | | All spawn strategies already treat all normal outputs as optional. Bazel checks at the action level whether all action outputs are created, but does not check at the spawn level. Spawn.getOptionalOutputs is therefore unnecessary, and removed in this change. The only place where this was set was in StandaloneTestStrategy, which now specifies the full set of outputs, which is now computed by TestRunnerAction. The internal test strategy implementations are also updated in this change. While I'm at it, also remove the use of BaseSpawn and use SimpleSpawn instead. This may go some way towards fixing #1413 and #942. -- PiperOrigin-RevId: 149397100 MOS_MIGRATED_REVID=149397100
* Rewrite TestStrategy.getArgsGravatar Ulf Adams2017-03-06
| | | | | | | | | | | | | | | | | | | | | | This changes command-line computation for tests: - run the coverage collector before the run_under command - no shell escaping: if all tools just call "$@", then this should work Note that we still wrap the command in a sub-shell to support shell built-ins and PATH lookup if the command does not contain a slash character '/'. A side effect of this change is that the --run_under command now executes in the test's runfiles directory, rather than in the exec root, if coverage is enabled at the same time. Inside Google, it's very rare for --run_under to be used in combination with coverage, and it seems likely to be rare externally as well, so I don't think it warrants covering it in the release notes. Also set TEST_BINARY to the root-relative path of the test executable for all tests (in TestRunnerAction.java). -- PiperOrigin-RevId: 149275688 MOS_MIGRATED_REVID=149275688
* Remove some unnecessary codeGravatar Ulf Adams2017-03-01
| | | | | | | | | | TestStrategy sometimes computed the runfiles directory separately from the existing code in Runfiles. Now we always use the passed through value. AFAICT, the two code paths were identical. -- PiperOrigin-RevId: 148866489 MOS_MIGRATED_REVID=148866489
* Rollback of commit 1cb5059396e46d9ff2c317b8a0a046af32b3a1d8.Gravatar Ulf Adams2017-02-20
| | | | | | | | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Breaks TEST_BINARY env setting if --run_under is used. *** Original change description *** Rewrite TestStrategy.getArgs This changes command-line computation for tests: - run the coverage collector before the run_under command - no shell escaping: if all tools just call "$@", then this should work Note that we still wrap the command in a sub-shell to support shell built-ins and PATH lookup if the command does not contain a slash character '/'. A side effect of this change is that the --run_under command now executes in the test's runfiles directory, rather than in the exec root, if... *** -- PiperOrigin-RevId: 148003525 MOS_MIGRATED_REVID=148003525
* Rewrite TestStrategy.getArgsGravatar Ulf Adams2017-02-17
| | | | | | | | | | | | | | | | | | | This changes command-line computation for tests: - run the coverage collector before the run_under command - no shell escaping: if all tools just call "$@", then this should work Note that we still wrap the command in a sub-shell to support shell built-ins and PATH lookup if the command does not contain a slash character '/'. A side effect of this change is that the --run_under command now executes in the test's runfiles directory, rather than in the exec root, if coverage is enabled at the same time. Inside Google, it's very rare for --run_under to be used in combination with coverage, and it seems likely to be rare externally as well, so I don't think it warrants covering it in the release notes. -- PiperOrigin-RevId: 147815017 MOS_MIGRATED_REVID=147815017
* Use the test's PATH to resolve the --run_under commandGravatar Ulf Adams2017-02-14
| | | | | | | | | | | | | | | | | | | The change that originally introduced local PATH lookup was made a very long time ago, and it's unclear what the exact reasons were. This change makes the local and remote test execution code paths more consistent, which minimizes surprises. Bazel currently forwards the local PATH by default, so this should be a no-op. Ideally, we'd require PATH forwarding to be explicit, e.g., with --action_env=PATH, --test_env=PATH, or --run_under=$(which command). RELNOTES[INC]: Bazel now uses the test's PATH for commands specified as --run_under; this can affect users who explicitly set PATH to a more restrictive value than the default, which is to forward the local PATH -- PiperOrigin-RevId: 147457058 MOS_MIGRATED_REVID=147457058
* Remove the first argument of TestStrategy.getArgs.Gravatar Ulf Adams2017-02-09
| | | | | | | | | All callers were performing identical steps before calling getArgs - move the functionality into getArgs instead. -- PiperOrigin-RevId: 147028753 MOS_MIGRATED_REVID=147028753
* Test strategy unification - extract env setup to a new classGravatar Ulf Adams2017-02-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce a new class TestPolicy that computes the test environment and use it from all the test strategies instead of the previous duplicated code. Note how the TestPolicy constructs the environment in four steps, each of which can override variables set in a previous step: 1. set env variables for which we have a hard-coded policy 2. set env variables from --action_env 3. set env variables from --test_env 4. set env variables that are specific to the test (path locations, coverage collection protocol, test sharding protocol, etc.); the code for this lives in TestRunnerAction This changes the order in which env variables are set, which can change the resulting environment if --test_env or --action_env are set. We should consider not allowing the command-line flags to override TEST_SRCDIR, RUNFILES_DIR, or TEST_TMPDIR. We should also try to find a way to drop the RUNTEST_PRESERVE_CWD variable in coverage mode. I'm fairly sure that it's current use breaks the combination of coverage and --run_under. My current thinking is that we change the test setup script to source the coverage collector before changing the CWD. Another option is to merge the coverage collector into the test setup script. -- PiperOrigin-RevId: 146237448 MOS_MIGRATED_REVID=146237448
* Don't short-circuit runfiles creation in tests if the output MANIFEST file ↵Gravatar Janak Ramakrishnan2017-01-31
| | | | | | | | is a symlink. That may indicate that it points to the input manifest, and so comparing the manifests in this case would be useless. -- PiperOrigin-RevId: 146048132 MOS_MIGRATED_REVID=146048132
* Move the test environment setup to the TestRunnerAction.Gravatar Ulf Adams2017-01-24
| | | | | | | | | | | | | | | | | | | This is part of unifying the test strategies; here, I'm working towards sharing the test environment setup. This change moves code from previously closed source code into the open source parts. The internal change is not visible, making this look like an addition rather than a move.. The next change hooks this up to Bazel. I did this in order to reduce the size of the change to make it easier to debug, review, and so that it's smaller in case we have to roll it back. Unfortunately, that requires duplicating some of the code in StandaloneTestStrategy until the next change lands. -- PiperOrigin-RevId: 145387109 MOS_MIGRATED_REVID=145387109
* Move the coverage-related methods from TestStrategy to TestRunnerAction.Gravatar Ulf Adams2017-01-20
| | | | | | | | | | This seems like an obvious cleanup, and I also want to move most of the test-specific environment setup to TestRunnerAction, which is simpler after this change. -- PiperOrigin-RevId: 145076829 MOS_MIGRATED_REVID=145076829
* Rollback of commit 87532156cf3ed7b66c6db5cb1e57dff7424031ab.Gravatar Kristina Chodorow2016-12-22
| | | | | | | | *** Reason for rollback *** -- PiperOrigin-RevId: 142691907 MOS_MIGRATED_REVID=142691907
* Gives detailed error message when fail to re-create directories during ↵Gravatar Yue Gan2016-12-20
| | | | | | | | | | testing. Also fixes bazel_test_test. Fixes #2228. -- PiperOrigin-RevId: 142532524 MOS_MIGRATED_REVID=142532524
* Move TestStrategy to lib.exec package.Gravatar Ulf Adams2016-12-15
This is part of refactoring test strategy to unify its implementation between Bazel and Blaze (Google's internal version of Bazel), which should fix several issues in Bazel. It's also necessary to untangle lib.rules and lib.exec to enforce proper layering by separating compilation of these packages, and to provide a minimal Bazel binary. In particular, no core part of Bazel should depend on any of the rules, to facilitate moving them out of Bazel / reimplementing them in Skylark (except for some core rules like test_suite, alias, and genquery). -- PiperOrigin-RevId: 142151901 MOS_MIGRATED_REVID=142151901