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

Add buildifier_test target #1597

Merged
merged 4 commits into from
Dec 15, 2021
Merged

Add buildifier_test target #1597

merged 4 commits into from
Dec 15, 2021

Conversation

k1nkreet
Copy link
Contributor

#951: Create buildifier_test target target instead of running build run //:buildifer from RunTests.hs

Depends on #1596

@k1nkreet k1nkreet requested a review from aherrmann September 21, 2021 10:55
@@ -18,9 +18,6 @@ import Test.Hspec (context, hspec, it, describe, runIO, shouldSatisfy, expectati

main :: IO ()
main = hspec $ do
it "bazel lint" $ do
assertSuccess (bazel ["run", "//:buildifier"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this also checked files under examples and tutorial which are not covered by the new buidifier_test with //:all_files. Any way to keep those checked as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to add them as a local_repositories providing same all_files targets and use them as srcs of buildifier_test

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Sounds like a good approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@aherrmann
Copy link
Member

I see that CI is failing on Windows with

ERROR(tools/test/windows/tw.cc:1288) ERROR: src/main/native/windows/process.cc(202): CreateProcessW("C:\users\runneradmin\_bazel_runneradmin\minshlu6\execroot\rules_haskell\bazel-out\x64_windows-fastbuild\bin\tests\buildifier_test.bash"): %1 is not a valid Win32 application.

This happens when a Bazel rule emits a script like a bash script as its executable. This works on Unix, but not on Windows where such files are not valid executables. I suspect this may be the issue here.

One way to fix this is to split the rule into two parts, one that fills in the script template and a separate native.sh_binary. We do this e.g. in cc_wrapper.

That said, I don't think we need to block this PR on that. Only checking formatting on Unix is sufficient and we can skip this test on Windows.

@k1nkreet
Copy link
Contributor Author

k1nkreet commented Oct 1, 2021

I've missed buildtools readme mentions explicitly Bazel target is not supported on Windows. This is actually true for run target used in RunTests.hs as well :)

@aherrmann
Copy link
Member

I've missed buildtools readme mentions explicitly Bazel target is not supported on Windows. This is actually true for run target used in RunTests.hs as well :)

Ah, good to know. Thanks for clarifying!

@k1nkreet
Copy link
Contributor Author

k1nkreet commented Oct 4, 2021

I've tagged this test as "dont_test_on_windows" so it should not be failing now.

@dpulls
Copy link

dpulls bot commented Oct 5, 2021

🎉 All dependencies have been resolved !

@k1nkreet
Copy link
Contributor Author

@aherrmann Is there anything else should be done here?

Copy link
Member

@aherrmann aherrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay.

One small comment. Otherwise, this looks great, thank you!

This may need a manual rebase. It looks like some changes from the prerequisite PR are still in here. I think dpulls only rebases if the PR's target branch is the dependency's branch.

"@examples//:all_files",
"@tutorial//:all_files",
],
tags = ["dont_test_on_windows"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tags = ["dont_test_on_windows"],
mode = ["diff"],
tags = ["dont_test_on_windows"],

I've tested this locally on a file with broken formatting and without this mode attribute I'm getting the error

buildifier: open ./external/examples-arm/BUILD.bazel: read-only file system

It looks like the default mode is fix and in test-mode these files are read-only.

The fix mode seems to only work with bazel run instead of bazel test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aherrmann
Copy link
Member

Rebase on master should fix the CI error. #1606 is merged.

@aherrmann aherrmann added the merge-queue merge on green CI label Oct 14, 2021
@k1nkreet k1nkreet force-pushed the ip/buildifier-test-target branch from 4da5c1c to 47075fa Compare December 15, 2021 10:15
@aspiwack aspiwack force-pushed the ip/buildifier-test-target branch from 47075fa to f434ca4 Compare December 15, 2021 10:57
@mergify mergify bot merged commit b58cfa3 into master Dec 15, 2021
@mergify mergify bot deleted the ip/buildifier-test-target branch December 15, 2021 11:39
@mergify mergify bot removed the merge-queue merge on green CI label Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants