--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAAVj6hwcT7wnJXyAF_rCACpOx7EUM6VgjRGfDyXoKNn5XOn5OA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAJMmbx%2BK%3DyixfXZqGu5cPvbva7pa8z%2B57DJ2Y8trHjr8zuOxZA%40mail.gmail.com.
I've been doing it by using bazel run when I want to update the test data instead of trying to get bazel test to update it.
AustinOn Thu, Feb 11, 2016 at 10:22 AM 'Eric Fellheimer' via bazel-discuss <bazel-...@googlegroups.com> wrote:Hmm, what about passing in a flag to your test that instructs it to save the file? You could pass in --test_arg=--save_golden_file=<path> ?
/proc
shall be mounted. All build tools shall be present at the absolute paths under /usr
used by a local installation. Paths starting with /home
may not be available. Tests should not access any such paths. /tmp
and /export/hda3/tmp
shall be writable, but tests should avoid using these paths. Tests must not assume that any constant path is available for their exclusive use. Tests must not assume that atimes are enabled for any mounted filesystem."Interesting advice.
/** ~Andrew Z Allen */On Thu, Feb 11, 2016 at 12:44 PM, Austin Schuh <austin...@gmail.com> wrote:I've been doing it by using bazel run when I want to update the test data instead of trying to get bazel test to update it.So bazel run runs in the context of the real repo instead of in the sandbox? Or are you reaching into bazel-out (or wherever the files pop out) and copying them into your repo?
AustinOn Thu, Feb 11, 2016 at 10:22 AM 'Eric Fellheimer' via bazel-discuss <bazel-...@googlegroups.com> wrote:Hmm, what about passing in a flag to your test that instructs it to save the file? You could pass in --test_arg=--save_golden_file=<path> ?To quote the test encyclopedia:"The root directory observed by a test may or may not be the real root directory./proc
shall be mounted. All build tools shall be present at the absolute paths under/usr
used by a local installation. Paths starting with/home
may not be available. Tests should not access any such paths./tmp
and/export/hda3/tmp
shall be writable, but tests should avoid using these paths. Tests must not assume that any constant path is available for their exclusive use. Tests must not assume that atimes are enabled for any mounted filesystem."I'm not sure if the sandboxing precludes writing to the normal file system. Based on my understanding of Bazel I think this would work but I'd like to make sure that I'm doing this in a way that won't silently break in the future.
Andrew,On Thu, Feb 11, 2016 at 8:13 PM Andrew Allen <m...@andrewzallen.com> wrote:Interesting advice.
/** ~Andrew Z Allen */On Thu, Feb 11, 2016 at 12:44 PM, Austin Schuh <austin...@gmail.com> wrote:I've been doing it by using bazel run when I want to update the test data instead of trying to get bazel test to update it.So bazel run runs in the context of the real repo instead of in the sandbox? Or are you reaching into bazel-out (or wherever the files pop out) and copying them into your repo?`bazel run` runs in the context of the host, after having built in the context of the sandbox. The directory that it runs from seems to be the runfiles directory of the binary, FYI. I use absolute paths when I want to write somewhere so I don't have to think as hard... You could very likely make relative paths work.
This doesn't solve your desire to log the output upon test failure though, which seems like a neat idea.
AustinOn Thu, Feb 11, 2016 at 10:22 AM 'Eric Fellheimer' via bazel-discuss <bazel-...@googlegroups.com> wrote:Hmm, what about passing in a flag to your test that instructs it to save the file? You could pass in --test_arg=--save_golden_file=<path> ?To quote the test encyclopedia:"The root directory observed by a test may or may not be the real root directory./proc
shall be mounted. All build tools shall be present at the absolute paths under/usr
used by a local installation. Paths starting with/home
may not be available. Tests should not access any such paths./tmp
and/export/hda3/tmp
shall be writable, but tests should avoid using these paths. Tests must not assume that any constant path is available for their exclusive use. Tests must not assume that atimes are enabled for any mounted filesystem."I'm not sure if the sandboxing precludes writing to the normal file system. Based on my understanding of Bazel I think this would work but I'd like to make sure that I'm doing this in a way that won't silently break in the future.Sandboxing should preclude writing to the host. The namespace is created with a lot of stuff bind mounted read-only. If that isn't true, it would most likely be considered a bug.
I hope this helps!Austin
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CABsbf%3DEd5vDB%3D3qvkjmovZ%2BKX_oVQCW788JNT4z04XRv%3D%2BjTJg%40mail.gmail.com.
Hi,I've got a bit more info about how some of this stuff works.On Thu, Feb 11, 2016 at 11:19 PM, Austin Schuh <austin...@gmail.com> wrote:Andrew,On Thu, Feb 11, 2016 at 8:13 PM Andrew Allen <m...@andrewzallen.com> wrote:Interesting advice.
/** ~Andrew Z Allen */On Thu, Feb 11, 2016 at 12:44 PM, Austin Schuh <austin...@gmail.com> wrote:I've been doing it by using bazel run when I want to update the test data instead of trying to get bazel test to update it.So bazel run runs in the context of the real repo instead of in the sandbox? Or are you reaching into bazel-out (or wherever the files pop out) and copying them into your repo?`bazel run` runs in the context of the host, after having built in the context of the sandbox. The directory that it runs from seems to be the runfiles directory of the binary, FYI. I use absolute paths when I want to write somewhere so I don't have to think as hard... You could very likely make relative paths work.The documentation says "the test's current directory (which is in the runfiles tree)", meaning the CWD for tests is guaranteed to be bazel-bin/package/target.runfiles. That directory tree has enough symlinks in it though that it's probably easier to just use absolute paths.
This doesn't solve your desire to log the output upon test failure though, which seems like a neat idea.Not sure if this makes sense for what you're doing, but you could print the contents of the new golden file (possibly encoded in some way and with delimiters) from the test and then have a separate script that extracts it from the test log file.
AustinOn Thu, Feb 11, 2016 at 10:22 AM 'Eric Fellheimer' via bazel-discuss <bazel-...@googlegroups.com> wrote:Hmm, what about passing in a flag to your test that instructs it to save the file? You could pass in --test_arg=--save_golden_file=<path> ?To quote the test encyclopedia:"The root directory observed by a test may or may not be the real root directory./proc
shall be mounted. All build tools shall be present at the absolute paths under/usr
used by a local installation. Paths starting with/home
may not be available. Tests should not access any such paths./tmp
and/export/hda3/tmp
shall be writable, but tests should avoid using these paths. Tests must not assume that any constant path is available for their exclusive use. Tests must not assume that atimes are enabled for any mounted filesystem."I'm not sure if the sandboxing precludes writing to the normal file system. Based on my understanding of Bazel I think this would work but I'd like to make sure that I'm doing this in a way that won't silently break in the future.Sandboxing should preclude writing to the host. The namespace is created with a lot of stuff bind mounted read-only. If that isn't true, it would most likely be considered a bug.
The root filesystem when running under the sandbox is made up of bind-mounted (read-only) files and directories and a temporary directory Bazel deletes afterwards for the root. Everything which is saved from the sandbox has to be explicitly copied before it gets cleaned up, which basically means only explicit outputs (none for tests) and a fixed set of logs etc for tests.
I hope this helps!
I think the recommended output location is $TEST_TMPDIR, which is
usually a sub-directory under bazel-$workspacename/_tmp.
As far as I can tell, there's still no way to preserve test artifacts in bazel, other than running it outside the sandbox. Can we have TEST_UNDECLARED_OUTPUTS_DIR supported in bazel?