aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell/bazel/skylark_repository_test.sh
Commit message (Collapse)AuthorAge
* External repositories: disallow use of unexported repository rulesGravatar Klaus Aehlig2018-07-17
| | | | | | | | | | | Treat repository rules the same way as build rules: they may only be used, if exported by a Skylark file. It has never been intended to create external repositories by anonymous rules, and, in fact, for properly recording resolved information, it is necessary that all repository rules used can be referred to by an accessible name. Change-Id: Ib9259d58be66b033721a6f591656c45889f49931 PiperOrigin-RevId: 204872735
* Split skylark flag tests into multiple test casesGravatar brandjon2017-10-25
| | | | | | | This is cleaner and will help when we eventually add tests for flags controlling the global environment. RELNOTES: None PiperOrigin-RevId: 173388860
* Propagate skylark flags to WORKSPACE and repo rulesGravatar brandjon2017-10-24
| | | | | RELNOTES: Skylark semantics flags now affect WORKSPACE files and repository rules. PiperOrigin-RevId: 173130286
* Check parameter types for methods when multiple types are allowed.Gravatar Dmitry Lomov2017-09-25
| | | | | | | | | | | | | | | Relanding https://github.com/bazelbuild/bazel/commit/17214ac78ffaec369d5d5bafe62a39730473cfaa with fixes to 'repository_ctx.download()' and 'repository_ctx.download_and_extract()'. I reviewed other usages of @ParamType annotation - I do not think there are more issues. Fixes #3714. Change-Id: I17087ef3fc2d28ab99224740a2164675a49847d3 PiperOrigin-RevId: 169896223
* Make the print function output debug messagesGravatar vladmos2017-08-11
| | | | | RELNOTES: The `print` function now prints debug messages instead of warnings. PiperOrigin-RevId: 164880003
* Make tests more portableGravatar Klaus Aehlig2017-08-04
| | | | | | | | | By replacing uses of /bin/bash by /bin/sh, a tool which is more reliably at this location. Then, enable most of the bazel tests for FreeBSD as well. Change-Id: Ic56a1705858f1ed67d1e96e2937e9389dd1d0e36 PiperOrigin-RevId: 164241635
* Print repository context's execute outputGravatar Kristina Chodorow2017-03-16
| | | | | | | | RELNOTES: Repository context's execute() function can print stdout/stderr while running. To enable, pass quiet=False. -- PiperOrigin-RevId: 150206218 MOS_MIGRATED_REVID=150206218
* Rollback of commit 4b73e972d909bcd533f2f9940f95a00b9b73bdde.Gravatar Dmitry Lomov2017-02-17
| | | | | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Broke tests on CI: http://ci.bazel.io/job/bazel-tests/570/ *** Original change description *** Roll forward execroot change RELNOTES[INC]: Previously, an external repository would be symlinked into the execution root at execroot/local_repo/external/remote_repo. This changes it to be at execroot/remote_repo. This may break genrules/Skylark actions that hardcode execution root paths. If this causes breakages for you, ensure that genrules are using $(location :target) to access files and Skylark rules are using http://bazel.io/docs/skylark/lib/File.html's path, dirname, etc. functions. Cust... -- PiperOrigin-RevId: 147833177 MOS_MIGRATED_REVID=147833177
* Roll forward execroot changeGravatar Kristina Chodorow2017-02-16
| | | | | | | | | | | | | | | | | RELNOTES[INC]: Previously, an external repository would be symlinked into the execution root at execroot/local_repo/external/remote_repo. This changes it to be at execroot/remote_repo. This may break genrules/Skylark actions that hardcode execution root paths. If this causes breakages for you, ensure that genrules are using $(location :target) to access files and Skylark rules are using http://bazel.io/docs/skylark/lib/File.html's path, dirname, etc. functions. Custom crosstools that hardcode external/<repo> paths will have to be updated. Issue #1262. -- PiperOrigin-RevId: 147726370 MOS_MIGRATED_REVID=147726370
* Skylark repositories: add FileValue hash codes to the marker file Gravatar Damien Martin-Guillerez2017-02-15
| | | | | | | | | | | | | | So that change to those files are seen and cause a refetch. Design doc: https://bazel.build/designs/2016/10/18/repository-invalidation.html [step 5] Fixes #1022. -- Change-Id: Ic75f2c9c59a4c91ff3e937ca21b37e74332c03ec Reviewed-on: https://cr.bazel.build/8218 PiperOrigin-RevId: 147574856 MOS_MIGRATED_REVID=147574856
* Skylark repositories: add a test to test correct invalidation with change to ↵Gravatar Damien Martin-Guillerez2017-02-14
| | | | | | | | | | | | | | | | | bzl files The marker file contains the hash of the Skylark extension from the ruleKey, see RuleFormatter.java#L44. Design doc: https://bazel.build/designs/2016/10/18/repository-invalidation.html [step 6] Issue #1022. -- Change-Id: I6da5e1f8797fa5ee20401ede29c67ccf1a8cef5a Reviewed-on: https://cr.bazel.build/8150 PiperOrigin-RevId: 147470732 MOS_MIGRATED_REVID=147470732
* Fix IllegalStateException when loading from a non declared external repository Gravatar Damien Martin-Guillerez2017-02-14
| | | | | | | | | | | This is another instance of #1793 that happens when a WORKSPACE file exists in some path underneath your current workspace. -- Change-Id: Idb01cd643548a170a27c9103f1b5081b058cc005 Reviewed-on: https://cr.bazel.build/8143 PiperOrigin-RevId: 147353935 MOS_MIGRATED_REVID=147353935
* Add environ attribute to repository_rule Gravatar Damien Martin-Guillerez2017-02-14
| | | | | | | | | | | | | | | | | | | This environ attribute let the repository rule implementor describes on which environment variable change a repository should be refetched. RELNOTES[NEW]: environ parameter to the repository_rule function let defines a list of environment variables for which a change of value will trigger a repository refetching. Design doc: https://bazel.build/designs/2016/10/18/repository-invalidation.html [step 3 & 4] Fixes #1595. -- Change-Id: Ibc2f93e69cb08baf86107cc9a9428b7a0eba1bac Reviewed-on: https://cr.bazel.build/8139 PiperOrigin-RevId: 147345203 MOS_MIGRATED_REVID=147345203
* Shard skylark_repository_test Gravatar Damien Martin-Guillerez2017-01-17
| | | | | | | | | | Also test_build_repo set-up that starts failing with sharding -- Change-Id: I9b950f1569737c52f9a4608eaad68db01f30ac82 Reviewed-on: https://cr.bazel.build/8144 PiperOrigin-RevId: 144631720 MOS_MIGRATED_REVID=144631720
* Skylark repositories: propage value from --action_env to repository_ctx.environ Gravatar Damien Martin-Guillerez2017-01-10
| | | | | | | | | | | | | | | | | | | | | | The environment is now computed with a mixture of the client environment and the values specified by the --action_env flag. If a user want to overwrite its environment for skylark repository, they can do `--action_env FOO=BAR` and the repository will see FOO as having the value BAR, whichever value is set in the client environment. Also propagate it to all repository functions, and deduplicate the way the client environment is passed to repository functions. Design doc: https://bazel.build/designs/2016/10/18/repository-invalidation.html [step 1] RELNOTES[INC]: repository_ctx environment is now affected by --action_env flag (value from the client environment will be replaced by value given on the command line through --action_env). -- Change-Id: I131a9695439aa9949d5001f820e2ae450e41332f Reviewed-on: https://cr.bazel.build/7971 PiperOrigin-RevId: 144091492 MOS_MIGRATED_REVID=144091492
* skylark_repository_test: use label in all load statement Gravatar Damien Martin-Guillerez2017-01-10
| | | | | | | | | | | | | | | | | | | This test was still using the old path syntax that is deprecated, use the label syntax instead. Note that there is still several instance of that old syntax in our tests: ``` grep -E -r 'load\(['"'"'"]/[^/]' src/test | wc -l 109 ``` -- Change-Id: Id2d1a9a525f1584136501026de01cf53e2263c3f Reviewed-on: https://cr.bazel.build/8135 PiperOrigin-RevId: 143967775 MOS_MIGRATED_REVID=143967775
* Allow url & output arguments to be namedGravatar Kristina Chodorow2016-12-21
| | | | | | | | This makes the skylark repository rules a little more flexible. -- PiperOrigin-RevId: 142663731 MOS_MIGRATED_REVID=142663731
* Create a proper wrapper script for executing "bazel" in the integration tests.Gravatar Luis Fernando Pino Duque2016-10-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently a call to "bazel" in an integration test means calling a (quite hidden) function in test-setup.sh which actually calls "$bazel" defined in "shell/bazel/testenv.sh" which is equal to "$(rlocation io_bazel/src/bazel)". This is extremely confusing and error prone. The new mechanism is to add a wrapper script to shell/bin called bazel and export this directory to the PATH. Moreover, not every test loads the same test environment, for instance consider how bazel_query_test loads the test environment: - Load shell/integration/testenv.sh which loads, - shell/bazel/test-setup.sh which loads, - shell/bazel/testenv.sh which loads, - shell/unittest.bash which loads, - shell/testenv.sh Again this is error prone and specially hard to understand, in fact each test writer needs to decide which of these testenv to load. This change fixes all of this by having only one testenv.sh and summarizing the test setup in integration_test_setup.sh. Namely, for any new integration test, the developer needs to load integration_test_setup to get the environment set up including the unittest framework (also it helps to attract contributions). This change also allows to open sourcing client_sigint_test: Since bazel was a function client_sigint_test was using a wrong process id to interrupt the build. The problem is that $! returns bash's id instead of the id of the process running in the background when using a function instead of an executable. A few tests needed to be adapted to the new infrastructure. -- MOS_MIGRATED_REVID=136470360
* Rollback of commit 82d43279f93d95e4c41b4bc598a3cc05ddd1ae1a.Gravatar Laszlo Csomor2016-09-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Breaks TensorFlow and other Bazel jobs on ci.bazel.io *** Original change description *** Change execution root for external repositories to be ../repo Some of the important aspect of this change: * Remote repos in the execution root are under output_base/execroot/repo_name, so the prefix is ../repo_name (to escape the local workspace name). * Package roots for external repos were previously "output_base/", they are now output_base/external/repo_name (which means source artifacts always have a relative path from their repository). * Outputs are under bazel-bin/external/repo_name/ (or similarly under genfiles). Note that this is a bit of a change from how this was implemented in the previous cl. Fixes #1262. RELNOTES[INC]: Previously, an external repository would be symlinked into the execution root at execroot/local_repo/external/remote_repo. This changes it to be at execroot/remote_repo. This may break genrules/Skylark actions that hardcode execution root paths. If this causes breakages for you, ensure that genrules are using $(location :target) to access files and Skylark rules are using http://bazel.io/docs/skylark/lib/File.html's path, dirname, etc. functions. Roll forward of bdfd58a. -- MOS_MIGRATED_REVID=133709658
* Change execution root for external repositories to be ../repoGravatar Kristina Chodorow2016-09-20
| | | | | | | | | | | | | | | | | | | | | | | Some of the important aspect of this change: * Remote repos in the execution root are under output_base/execroot/repo_name, so the prefix is ../repo_name (to escape the local workspace name). * Package roots for external repos were previously "output_base/", they are now output_base/external/repo_name (which means source artifacts always have a relative path from their repository). * Outputs are under bazel-bin/external/repo_name/ (or similarly under genfiles). Note that this is a bit of a change from how this was implemented in the previous cl. Fixes #1262. RELNOTES[INC]: Previously, an external repository would be symlinked into the execution root at execroot/local_repo/external/remote_repo. This changes it to be at execroot/remote_repo. This may break genrules/Skylark actions that hardcode execution root paths. If this causes breakages for you, ensure that genrules are using $(location :target) to access files and Skylark rules are using http://bazel.io/docs/skylark/lib/File.html's path, dirname, etc. functions. Roll forward of bdfd58a. -- MOS_MIGRATED_REVID=133606309
* Use named parameters for function in SkylarkRepositoryContext when it make senseGravatar Damien Martin-Guillerez2016-09-07
| | | | | | | | | | | | | | RELNOTES[INC]: repository_ctx.{download,download_and_extract,execute} API now use named parameters for optional parameters and no longer uses argument type to distinguished between arguments (executable attribute name must be specified when preceding optional arguments are missing). Fixes #1426. -- Change-Id: I41d174cd9fd5c47edf4e2e9a86ce7f6c7882a104 Reviewed-on: https://bazel-review.googlesource.com/#/c/5673 MOS_MIGRATED_REVID=132421955
* Use a mutable map when collecting environment variables for ↵Gravatar Chris Parsons2016-06-29
| | | | | | | repository_ctx.execute, so that it allows overriding current environment variables -- MOS_MIGRATED_REVID=126089693
* Make skylark repository rules accept basic rule attributesGravatar Kristina Chodorow2016-06-21
| | | | | | | Fixes #1314. -- MOS_MIGRATED_REVID=125340361
* Rollback of commit bdfd58a8ca2ed5735d6aaa5b238fb0f689515724.Gravatar Laurent Le Brun2016-06-20
| | | | | -- MOS_MIGRATED_REVID=125160288
* Make the execution root match the runfiles tree structure for external ↵Gravatar Kristina Chodorow2016-06-17
| | | | | | | | | | | | | | | | | | | | | repositories One interesting side effect of how this is implemented is that for external repositories, bin/ and genfiles/ are combined. External repo output is under bazel-out/local-fastbuild/repo_name for each repo. Fixes #1262. RELNOTES[INC]: Previously, an external repository would be symlinked into the execution root at execroot/local_repo/external/remote_repo. This changes it to be at execroot/remote_repo. This may break genrules/Skylark actions that hardcode execution root paths. If this causes breakages for you, ensure that genrules are using $(location :target) to access files and Skylark rules are using http://bazel.io/docs/skylark/lib/File.html's path, dirname, etc. functions. -- MOS_MIGRATED_REVID=125095799
* Create the output directory when invoking repository_ctx.download_and_extractGravatar Damien Martin-Guillerez2016-06-06
| | | | | | | Fixes #1172. -- MOS_MIGRATED_REVID=124122716
* repository_ctx.execute: execute from the external repository root and allow ↵Gravatar Damien Martin-Guillerez2016-06-06
| | | | | | | | | | to override the environment variables. Fixes #1130 Fixes #1242 -- MOS_MIGRATED_REVID=124118789
* Use setLoadingOrWorkspacePhase instead of setLoadingPhase where relevant,Gravatar Damien Martin-Guillerez2016-05-23
| | | | | | | | | | | commit 3fedf9e618cbce3dbdd00559b2de0bb8e2d43171 introduced the distinction between the loading phase and the workspace phase. This check broke the use of native.existing_rule(s) in skylark remote repository, added a regression test for it. Fixes #1277 -- MOS_MIGRATED_REVID=122988569
* Add a workspace name to Skylark repositoriesGravatar Kristina Chodorow2016-04-21
| | | | | | | | | This prevents an ugly error when the main repository name is set. Fixes #1166. -- MOS_MIGRATED_REVID=120352395
* Add executable argument to repository_ctx.download function.Gravatar Yun Peng2016-03-24
| | | | | | | | | | | repository.download function now creates the necessary directories before downloading. Fixes #1069 Fixes #1078 -- MOS_MIGRATED_REVID=118026986
* Deflake skylark_repository_testGravatar Damien Martin-Guillerez2016-03-21
| | | | | | | | | Use -p when mkdir, create the server directory in the temporary directory and ensure we delete the server directory on the tear_down. -- MOS_MIGRATED_REVID=117728350
* Make labels in .bzl files in remote repos resolve relative to their repoGravatar Kristina Chodorow2016-03-21
| | | | | | | | | | | | | | | | | | For example, if you have a BUILD file that does: load('@foo//bar:baz.bzl', 'my_rule') my_rule(...) If baz.bzl uses Label('//whatever'), this change makes //whatever resolve to @foo//whatever. Previous to this change, it would be resolved to the repository the BUILD file using my_rule was in. RELNOTES[INC]: Labels in .bzl files in remote repositories will be resolved relative to their repository (instead of the repository the Skylark rule is used in). -- MOS_MIGRATED_REVID=117720181
* Add repository_ctx.download and repository_ctx.extract function.Gravatar Yue Gan2016-03-21
| | | | | | | | | Fixes #1041 RELNOTES: Add repository_ctx.download and repository_ctx.download_and_extract function. -- MOS_MIGRATED_REVID=117698142
* Add detection of WORKSPACE cycles due to load statementsGravatar Damien Martin-Guillerez2016-03-18
| | | | | | | | | Cycle when looking for a repository name will now shows a user-understable error. Fixes #877. -- MOS_MIGRATED_REVID=117453646
* Adds bazel_version to the native module for workspace macros.Gravatar Damien Martin-Guillerez2016-03-15
| | | | | | | | | | | | | | | | | | | | | One can now invoke native.bazel_version to get the version of Bazel from the WORKSPACE file. This can be used to do version check, for instance: version.bzl: def check_version(x): if native.bazel_version < x: fail("Current Bazel version is {}, expected at least {}".format(native.bazel_version, x)) WORKSPACE: load("//:version.bzl", "check_bersion") check_version("0.2") Fixes #1014. -- MOS_MIGRATED_REVID=117231557
* Use repository_ctx for each usage of repository context.Gravatar Damien Martin-Guillerez2016-03-14
| | | | | | | | This will avoid confusion with the normal Skylark rule context. Also fixed indentation of cc_configure.bzl -- MOS_MIGRATED_REVID=117011107
* Correctly report stderr content for repository_ctx.executeGravatar Damien Martin-Guillerez2016-03-04
| | | | | | | | | The shell.Command class throw an exception when exit code is non null, resulting in unwanted case where calling a failing command as just echoing "Exited with status 4". -- MOS_MIGRATED_REVID=116361594
* Use client environment for repository_ctx.which path environmentGravatar Damien Martin-Guillerez2016-02-29
| | | | | | | | This unify the way which() and os.environ() get their environment and won't lead to weird issue. -- MOS_MIGRATED_REVID=115829154
* Adds an executable argument to repository_ctx.file and repository_ctx.templateGravatar Damien Martin-Guillerez2016-02-28
| | | | | | | | | | We sometime want to execute the created file. The executable argument permit to control the executable bit on the created file. Issue #893 -- MOS_MIGRATED_REVID=115653127
* Testing correct invalidation of Skylark Remote RepositoriesGravatar Damien Martin-Guillerez2016-02-25
| | | | | | | | | | | | | | | | | | A Skylark remote repository should be invalidated only when the WORKSPACE file change, or one of its dependency or the Skylark file change. This change include two fixes: - The path of the RepositoryDirectoryValue was incorrect when the directory root is a symlink and the repository is not local (and not refetching). This was never triggered before because the only rule that were symlinking their root were the local one. - Directories were unitialized for the SkylarkRepositoryFunction (was forgotten as part of a refactor when introducing it). -- MOS_MIGRATED_REVID=115547540
* Implements repository_ctx.osGravatar Damien Martin-Guillerez2016-02-23
| | | | | | | | | | | repository_ctx.os gives access to os related information: - .system returns the name of the current platform. - .environ returns the list of environment variables. Issue #893: Step 4 of http://goo.gl/OZV3o0. See http://goo.gl/fD4ZsY. -- MOS_MIGRATED_REVID=115337406
* Implements repository_ctx.executeGravatar Damien Martin-Guillerez2016-02-23
| | | | | | | | | | This add a repository_ctx.execute() method for spawning action from a skylark remote repository. Issue #893: Step 4 of http://goo.gl/OZV3o0. See http://goo.gl/fD4ZsY. -- MOS_MIGRATED_REVID=115335198
* Introduce SkylarkRepositoryModuleGravatar Damien Martin-Guillerez2016-02-17
| | | | | | | | | | | | | | | | | The SkylarkRepositoryModule declare the `repository_rule` function to Skylark to define new remote repository types (http://goo.gl/OZV3o0). The work is delagated to the `SkylarkRepositoryFunction` by the `RepositoryDelegatorFunction`. `SkylarkRepositoryContext` defines the `ctx` object passed to the `repository_rule` implementation function. This change also introduce a `SkylarkPath` and the necessary methods in `SkylarkRepositoryContext` to showcase the creation of a `local_repository` like repository. Issue #893: step 3 of the roadmap http://goo.gl/OZV3o0. -- MOS_MIGRATED_REVID=114895003
* Prevent load statements in remote repository's WORKSPACE file to breakGravatar Damien Martin-Guillerez2016-02-12
| | | | | | | | | | | | | | | If a load statements was present in a remote repository's WORKSPACE file, the parsing of the WORKSPACE file to get the workspace name will break the build because it tries to load the Skylark extension from the main repository. This change replace the parsing of the whole remote repository's WORKSPACE file by a parsing of only it first chunk (before the first load statement). This change also enforce that the workpace() function to be called only from the top of the WORKSPACE file. -- MOS_MIGRATED_REVID=114528640
* Allow load of external label in the WORKSPACE file.Gravatar Damien Martin-Guillerez2016-02-10
| | | | | | | | | | | | | | | | | Issue #824 Step 5. The only thing left to resolve issue #824 are correct handling of the following cases: - Forbidding overloading of a repository outside of the first part of the workspace file (or it will leads to incorrectness issue and the only use-case is the redefinition of the bazel_tools repository). - Better error reporting when trying to refer to a non-existent repository from the workspace file, for now it will print a SkyFrame cycle exception. -- MOS_MIGRATED_REVID=114316464
* Disallow loads from external repos in WORKSPACE files. Currently, attempting ↵Gravatar John Field2016-01-18
| | | | | | | | | to do such a load will result in a skyframe circular dependency exception. As a side effect of this change, SkylarkImportFailedExceptions thrown by SkylarkImportLookupFunction are now caught by PackageFunction and wrapped and rethrown as a PackageFunctionException. Previously, the first exception wasn't caught, generating an uncaught exception error at top level. -- MOS_MIGRATED_REVID=112328755
* Only depend on the WORKSPACE file for external files that are under the ↵Gravatar Lukacs Berki2015-12-16
| | | | | | | | | | | | | | | external/ directory, i.e. were created by Bazel. This avoids a cycle that arose when a file is load()ed from the WORKSPACE file that is reached through a symlink to an external directory: * The WORKSPACE file depends on the package lookup node of the .bzl file * The package lookup node (transitively) depends on wherever the symlink points * The target of the symlink is an external file and as such, it depends on the WORKSPACE file This will probably be, erm, interesting to solve when we get as far as to load stuff from external repositories in the WORKSPACE file, but we are just not there yet. -- MOS_MIGRATED_REVID=110344658
* Add invalidation test when a Skylark file loaded from the WORKSPACE changeGravatar Damien Martin-Guillerez2015-12-02
| | | | | | | Fixes #672 -- MOS_MIGRATED_REVID=109174420
* Enable load() statement in the WORKSPACE file.Gravatar Damien Martin-Guillerez2015-11-30
RELNOTES[NEW]: Skylark macros are now enabled in WORKSPACE file. Design document at https://docs.google.com/document/d/1jKbNXOVp2T1zJD_iRnVr8k5D0xZKgO8blMVDlXOksJg/preview Fixes #337 -- MOS_MIGRATED_REVID=108860301