-
Notifications
You must be signed in to change notification settings - Fork 264
[Lagobot 2.0] part 1: generate testscript for a single devbox example project #799
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
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
4e0d10a
to
104c240
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the idea of having a run-test
script in each example's devbox.json
, but I'm not 100% clear on what testscripts is being used for. Couldn't we just invoke devbox run run_test
with an empty-ish environment directly?
// Golang caches build outputs for reuse in future builds in GOCACHE | ||
goBuildCache := filepath.Join(cacheHome, "go-build") | ||
env.Setenv("GOCACHE", goBuildCache) | ||
if err = os.MkdirAll(goBuildCache, 0755); err != nil { | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be set instead of using the default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without this I get the following error:
failed to initialize build cache at /no-home/Library/Caches/go-build: mkdir /no-home: read-only file system
its because GOCACHE
is likely set to $HOME/Library/Caches/go-build
and testscripts sets $HOME
to /no-home
.
// RunExamplesTestscripts generates testscripts for each example devbox-project. | ||
// For now, we prototype with the "go" example project. TODO savil: generalize. | ||
func RunExamplesTestscripts(t *testing.T, examplesDir string) { | ||
wd, err := os.Getwd() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go always runs tests from the package's directory, so you should be able to just refer to ../examples
directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I see. I drop this in the part 2 PR then (to simplify merging).
// implementation detail: the period at the end of the projectDir/. | ||
// is important to ensure this works for both mac and linux. | ||
// Ref.https://dev.to/ackshaey/macos-vs-linux-the-cp-command-will-trip-you-up-2p00 | ||
err = exec.Command("cp", "-r", projectDir+"/.", env.WorkDir).Run() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you run cp
in run_test.test.txt
and then not have to worry about the platform differences?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm wouldn't the cp
command still come from the underlying platform?
} | ||
}() | ||
|
||
// create a temp-dir to place the testscript file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't testscript
run the test in a temp dir?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does, which is the workDir
we refer to elsewhere in this PR.
What this is doing is generating a directory that holds the "project that has to be tested", which would normally have the .test.txt
file. I could simplify this by generating a single temp-dir, instead of re-generating this temp-dir for each example (as I do in part 2 PR).
Will revisit if I can just do a single temp-dir for all examples projects.
@@ -0,0 +1 @@ | |||
exec devbox run run_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will we be adding specific testscripts for other examples? If the testscript is just running devbox run run_test
why not do that directly in a regular test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The motivation is ensuring isolation is better...
104c240
to
cfe20ee
Compare
Summary
Why
Our goal is to make each Devbox release higher-quality by ensuring that all the devbox-projects in
examples/
are able to run.What
We aim to do so by adding a
run_test
devbox script to each project inexamples/
, and ensuring that it can run. This has the additional benefit of making thedevbox.json
self-documenting for any user who is reading the code in theexamples/
directory: they can refer to therun_test
to understand how to execute that example project.How
To do so in our automated tests:
devbox run run_test
.As a proof of concept, this PR runs a testscript for the
examples/development/go/hello-world
project. A future PR will generalize this to all of the devbox projects inexamples/
How was it tested?
Ran with this command: