Skip to content
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

test: add case for filegroup of srcs #211

Merged
merged 2 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
52 changes: 52 additions & 0 deletions examples/srcs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""Shows different ways to pass source files into ts_project"""

load("@aspect_bazel_lib//lib:params_file.bzl", "params_file")
load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")

# By default, the macro collects all .ts files in this directory.
# See the docs on srcs for exactly which files are included.
ts_project(
name = "srcs-auto",
out_dir = "auto",
)

# The sources can come from the default output of some other target.
# In this case, the ts_project macro won't be able to enumerate individual files
# so it cannot pre-declare the corresponding .js outputs.
filegroup(
name = "srcs",
srcs = glob(["*.ts"]),
)

ts_project(
name = "srcs-filegroup",
srcs = [":srcs"],
out_dir = "filegroup",
)

# Testing what outputs are actually produced
[
params_file(
name = "srcs-{}_mf".format(case),
out = "srcs-{}.mf".format(case),
args = ["$(rootpaths :srcs-{})".format(case)],
data = [":srcs-" + case],
)
for case in [
"auto",
"filegroup",
]
]

[
assert_contains(
name = "test_" + case,
actual = "srcs-{}.mf".format(case),
expected = "examples/srcs/{}/a.js".format(case),
)
for case in [
"auto",
"filegroup",
]
]
1 change: 1 addition & 0 deletions examples/srcs/a.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const a: string = 'a'
1 change: 1 addition & 0 deletions examples/srcs/b.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const b: string = 'b'
1 change: 1 addition & 0 deletions examples/srcs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}