Skip to content

Replace relative paths to ../ with external/ #1500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ filegroup(
)

local_repository(
name = "strip_resource_external_workspace",
path = "third_party/test/strip_resource_external_workspace",
name = "example_external_workspace",
path = "third_party/test/example_external_workspace",
)

load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_unused_deps_toolchains")
Expand Down
2 changes: 1 addition & 1 deletion scala/private/phases/phase_runfiles.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def phase_runfiles_library(ctx, p):
def phase_runfiles_scalatest(ctx, p):
args = "\n".join([
"-R",
ctx.outputs.jar.short_path,
ctx.outputs.jar.short_path.replace("../", "external/"),
_scala_test_flags(ctx),
"-C",
ctx.attr.reporter_class,
Expand Down
2 changes: 1 addition & 1 deletion scala/private/phases/phase_write_executable.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def phase_write_executable_scalatest(ctx, p):
rjars = p.coverage_runfiles.rjars,
jvm_flags = [
"-DRULES_SCALA_MAIN_WS_NAME=%s" % ctx.workspace_name,
"-DRULES_SCALA_ARGS_FILE=%s" % p.runfiles.args_file.short_path,
"-DRULES_SCALA_ARGS_FILE=%s" % p.runfiles.args_file.short_path.replace("../", "external/"),
] + expand_location(ctx, final_jvm_flags),
use_jacoco = ctx.configuration.coverage_enabled,
)
Expand Down
8 changes: 8 additions & 0 deletions test/scala_test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ scala_test(
],
reporter_class = "test.scala_test.CustomReporter",
)

# Check that we can run scala tests in external workspaces.
test_suite(
name = "external_scala_test",
tests = [
"@example_external_workspace//test:empty_test",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ scala_specs2_junit_test(
srcs = ["ResourceStripPrefixTest.scala"],
suffixes = ["Test"],
unused_dependency_checker_mode = "off",
deps = ["@strip_resource_external_workspace//strip:noSrcsWithResources"],
deps = ["@example_external_workspace//strip:noSrcsWithResources"],
)
47 changes: 47 additions & 0 deletions third_party/test/example_external_workspace/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
workspace(name = "example_external_workspace")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazel_skylib",
sha256 = "b8a1527901774180afc798aeb28c4634bdccf19c4d98e7bdd1ce79d1fe9aaad7",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz",
],
)

local_repository(
name = "io_bazel_rules_scala",
path = "../../..",
)

load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")

scala_config()

load(
"@io_bazel_rules_scala//scala:scala.bzl",
"rules_scala_setup",
"rules_scala_toolchain_deps_repositories",
)

rules_scala_setup()

rules_scala_toolchain_deps_repositories(fetch_sources = True)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")

scala_register_toolchains()

load("@io_bazel_rules_scala//testing:scalatest.bzl", "scalatest_repositories", "scalatest_toolchain")

scalatest_repositories()

scalatest_toolchain()
6 changes: 6 additions & 0 deletions third_party/test/example_external_workspace/test/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_test")

scala_test(
name = "empty_test",
srcs = ["EmptyTest.scala"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import org.scalatest.funsuite._

class EmptyTest extends AnyFunSuite {
test("empty test") {
assert(true)
}
}

This file was deleted.