google / starlark-go

Starlark in Go: the Starlark configuration language, implemented in Go
BSD 3-Clause "New" or "Revised" License
2.27k stars 204 forks source link

avoid cross-package references in tests #385

Closed adonovan closed 2 years ago

adonovan commented 2 years ago

The previous implementation of DataFile (which abstracts different build systems' ways of locating test data files) constructed file names of data files using $GOPATH; also, it used a cross-package reference to locate the assert.star file. This doesn't work under Go modules. Now, DataFile looks only in the current directory, and the assert.star file is moved into a constant section of the executable.

Also, fix tests historically broken on Mac/Windows due to diff and CR LF differences.

adonovan commented 2 years ago

+2, looks like the tests are happy. And thanks for fixing this. Sorry for the unexpected work.

No, thank you for making our automated tests run again, and on Darwin + Windows for (apparently) the first time.

I always forget that Git rewrites line endings on checkout in Windows. Making the test code tolerate that seems like the best way to fix it.

Yeah, I forgot that too. Presumably at this point in history every program in Darwin and Windows can handle UNIX line endings, which does make me wonder why programs continue to emit them.

With modules, cross-package references are okay, as long as they're in the same module.

Ah, good point, that would have worked. Still, I'm happy with this approach.