Skip to content

THRIFT-6348: Go tests: stop writing ThriftTest.thrift copies into the source tree - #3944

Merged
Jens-G merged 1 commit into
apache:masterfrom
slachiewicz:THRIFT-6348
Oct 20, 2026
Merged

Jens-G merged 1 commit into
apache:masterfrom
slachiewicz:THRIFT-6348

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

lib/go/test and test/go wrote copies of test/ThriftTest.thrift into the source tree, hidden by .gitignore. The filtered copy in lib/go/test now goes to a dedicated build/ directory, found with -I build and removed by make clean, and test/go compiles test/ThriftTest.thrift directly. The two .gitignore entries for the in-tree copies are replaced by one for lib/go/test/build/.

Verified: the old and new IncludesTest.thrift recipes → identical gopath/src (20 files).

  • Did you create an Apache Jira ticket? THRIFT-6348
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit?
  • Did you do your best to avoid breaking changes? No.
  • Code change, so the commit carries no CI-skip marker.
  • No new test: build change; the lib-go CI job runs both rules (make -C lib/go check, make -C test/go check).
  • AI-assisted: the commit carries a Co-Authored-By: trailer. No new dependency or third-party code.

@slachiewicz
slachiewicz requested a review from fishy as a code owner September 23, 2026 06:28
@mergeable mergeable Bot added golang Pull requests that update Go code build and general CI cmake, automake and build system changes labels Sep 23, 2026
@fishy

fishy commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

I'm not sure putting .thrift files into gopath is a good idea. Is there any particular issue with the current approach you are trying to fix, besides one more .gitignore'd file?

@slachiewicz

Copy link
Copy Markdown
Member Author

Hi @fishy,

Thanks for the review!

The motivation behind THRIFT-6348 is twofold:

  1. State-dependent IDL resolution & tree sweeping: IncludesTest.thrift and NamespacedTest.thrift have include "ThriftTest.thrift". Before make check is run, lib/go/test/ThriftTest.thrift does not exist in the source tree, so IDEs, language servers, or any tree-wide .thrift sweeps fail to resolve the include. Once make check runs, it leaves a generated/ephemeral IDL copy sitting directly in the source directory.
  2. Redundant copy in test/go: test/go/Makefile.am was doing an exact cp $(THRIFTTEST) ThriftTest.thrift with zero edits, which is completely unnecessary since $(THRIFTCMD) can compile $(THRIFTTEST) directly.

Regarding placing it in gopath/: I placed the filtered copy under gopath/ simply because gopath/ is already created and removed by clean-local: $(RM) -r gopath.

If you prefer keeping gopath/ strictly for Go packages, I can easily write the filtered copy to a dedicated directory like build/ThriftTest.thrift or gen-thrift/ThriftTest.thrift (and pass -I build) instead.

Would you prefer a dedicated build/ directory for the filtered file, or do you have a preferred location in mind?

@fishy

fishy commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

a dedicated directory would be better. gopath is supposed to be a directory managed by go toolchain.

build/ works for me.

@slachiewicz
slachiewicz marked this pull request as draft September 27, 2026 13:30
@slachiewicz

slachiewicz commented Oct 1, 2026 •

Copy link
Copy Markdown
Member Author

@fishy moved the filtered copy to a dedicated lib/go/test/build/ directory in 33696ef; gopath no longer holds any .thrift file.

@slachiewicz
slachiewicz marked this pull request as ready for review October 1, 2026 15:55
Copilot AI balanced review requested due to automatic review settings October 1, 2026 15:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Legacy generated files can shadow the new build input or remain after cleanup.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Moves Go test IDL generation out of the source tree.

Changes:

  • Compiles the shared Go test IDL directly.
  • Generates filtered IDL under lib/go/test/build/.
  • Updates cleanup and ignore rules.
File Description
.gitignore Replaces obsolete generated-IDL exclusions.
lib/​go/​test/​Makefile.am Generates filtered IDL in build/.
test/​go/​Makefile.am Compiles the canonical IDL directly.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/go/test/Makefile.am Resolved
Comment thread test/go/Makefile.am Resolved
@slachiewicz

Copy link
Copy Markdown
Member Author

@fishy Copilot raised two points about checkouts that ran make before this change (fresh clones and CI are not affected):

  1. Stale copy can shadow the new input. The compiler resolves a relative include next to the including file before the -I paths (compiler/cpp/src/thrift/main.cc, include path search), so a leftover lib/go/test/ThriftTest.thrift from an older build would be picked up by IncludesTest.thrift instead of build/ThriftTest.thrift.
  2. Cleanup of the old copies is gone. With ThriftTest.thrift dropped from clean-local (and from .gitignore), those leftovers show up in git status and make clean no longer removes them.

A possible fix, kept small:

--- a/lib/go/test/Makefile.am
+++ b/lib/go/test/Makefile.am
 	mkdir -p gopath/src build
+	# Older builds generated ThriftTest.thrift here. The compiler resolves an
+	# include next to the including file before the -I paths, so a leftover
+	# copy would shadow build/ThriftTest.thrift.
+	$(RM) ThriftTest.thrift
 	grep -v 'set<Insanity>' $(THRIFTTEST) > build/ThriftTest.thrift
@@
 clean-local:
-	$(RM) -r gopath build gen-go
+	$(RM) -r gopath build gen-go ThriftTest.thrift
--- a/test/go/Makefile.am
+++ b/test/go/Makefile.am
 clean-local:
-	$(RM) -r src/gen src/github.com/golang src/thrift bin pkg gopath
+	$(RM) -r src/gen src/github.com/golang src/thrift bin pkg gopath ThriftTest.thrift

Which direction do you prefer?

  • add this transitional cleanup to the PR, or
  • keep the PR as it is and rely on a one-time git clean for existing checkouts?

Happy to go either way.

@fishy

fishy commented Oct 1, 2026

Copy link
Copy Markdown
Member

the current make clean already would clean up ThriftTest.thrift:

$ make clean
rm -rf .libs _libs
rm -f -r gopath ThriftTest.thrift gen-go
rm -f *.lo

so I think that's good enough as-is?

@slachiewicz

Copy link
Copy Markdown
Member Author

Agreed — keeping it as-is, then. Thanks!

@Jens-G

Jens-G commented Oct 13, 2026

Copy link
Copy Markdown
Member

This branch has conflicts that must be resolved.

@Jens-G

Jens-G commented Oct 18, 2026

Copy link
Copy Markdown
Member

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@Jens-G

Jens-G commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

@slachiewicz This branch has conflicts that must be resolved

… source tree

Client: go

lib/go/test wrote a filtered copy next to the sources and test/go a
plain one; both were gitignored, so a checkout's IDL set depended on
whether a build had run. Write the filtered copy under build/ and
resolve the include with -I; use test/ThriftTest.thrift directly in
test/go.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 19, 2026 23:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Jens-G
Jens-G merged commit a9d4626 into apache:master Oct 20, 2026
109 checks passed
@slachiewicz
slachiewicz deleted the THRIFT-6348 branch October 28, 2026 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build and general CI cmake, automake and build system changes golang Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants