forked from bazel-contrib/rules_go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In new_go_repository, generate BUILD.bazel files by default
Generated BUILD files may conflict with other files or directories named "build" on case insensitive file systems. "BUILD.bazel" is less likely to conflict, and Bazel supports these files since 0.4.1. The filename can still be overridden by specifying the build_file_name attribute. This just changes the default. Fixes bazel-contrib#144
- Loading branch information
Jay Conrod
committed
Apr 17, 2017
1 parent
78d030f
commit 7747ea7
Showing
7 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_prefix", "go_test") | ||
|
||
go_prefix("local") | ||
|
||
go_test( | ||
name = "go_default_test", | ||
srcs = ["local_test.go"], | ||
tags = ["manual"], | ||
deps = ["@remote//build:go_default_library"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
local_repository( | ||
name = "io_bazel_rules_go", | ||
path = "@@RULES_DIR@@", | ||
) | ||
load("@io_bazel_rules_go//go:def.bzl", "go_repositories", "new_go_repository") | ||
go_repositories() | ||
|
||
new_go_repository( | ||
name = "remote", | ||
importpath = "remote", | ||
remote = "@@WORKSPACE_DIR@@/remote", | ||
vcs = "git", | ||
tag = "1.0", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package local | ||
|
||
import ( | ||
"testing" | ||
|
||
"remote/build" | ||
) | ||
|
||
func TestBuildValue(t *testing.T) { | ||
if got, want := build.Foo, 42; got != want { | ||
t.Errorf("got %d; want %d", got, want) | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
tests/new_go_repository_build_name/new_go_repository_build_name.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2017 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# This script tests that new_go_repository can be used to build a | ||
# package named "build" without explicitly specifying | ||
# "build_file_name". In #144, Gazelle would fail on case insensitive | ||
# file systems because "build" looks the same as "BUILD". In | ||
# new_go_repository, Gazelle should name files "BUILD.bazel" by | ||
# default. | ||
|
||
set -euo pipefail | ||
|
||
TEST_DIR=$(cd $(dirname "$0"); pwd) | ||
RULES_DIR=$(cd "$TEST_DIR/../.."; pwd) | ||
WORKSPACE_DIR=$(mktemp -d) | ||
|
||
function cleanup { | ||
rm -rf "$WORKSPACE_DIR" | ||
} | ||
trap cleanup EXIT | ||
|
||
cp -r "$TEST_DIR"/* "$WORKSPACE_DIR" | ||
|
||
cd "$WORKSPACE_DIR/remote" | ||
git init | ||
git add -A . | ||
git commit -m 'initial commit' | ||
git tag 1.0 | ||
|
||
cd "$WORKSPACE_DIR/local" | ||
sed \ | ||
-e "s|@@RULES_DIR@@|$RULES_DIR|" \ | ||
-e "s|@@WORKSPACE_DIR@@|$WORKSPACE_DIR|" \ | ||
<WORKSPACE.in >WORKSPACE | ||
bazel test \ | ||
--genrule_strategy=standalone \ | ||
--spawn_strategy=standalone \ | ||
//:go_default_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package build | ||
|
||
const Foo = 42 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters