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

ocamltest+testsuite: by default, only keep test data on failure #9414

Merged
merged 5 commits into from
Apr 2, 2020

Conversation

gasche
Copy link
Member

@gasche gasche commented Apr 1, 2020

On my machine, running the whole testsuite generates 1.5Gio of test
data. I have 11 workdirs for the OCaml repository (versions from 4.08
to trunk, plus several experimental workdirs); at any point in time
there can be more than a dozen gibibytes of test data on my disk, and
this is too much. (I found this when I ran into space storage issue
on my development machine and looked at the culprits.)

I use the test data saved by ocamltest when a test fails, to diagnose
the failure. I don't remember ever looking at the test data of
a succesful test.

The present patchset changes ocamltest to, by default, discard the
test data of succesful tests. If one wishes to preserve the test
data on a succesful test, one should explicitly pass the
-keep-data-on-success flag. The testsuite/Makefile is then changed
to pass this flag if the user set the KEEP_DATA_ON_SUCCESS variable
to a non-empty value.

@gasche
Copy link
Member Author

gasche commented Apr 1, 2020

(cc @shindere @Armael @nojb)

@Armael
Copy link
Member

Armael commented Apr 2, 2020

(so shouldn't the title be "only keep test data for failing builds"?)

@gasche gasche changed the title ocamltest+testsuite: by default, only keep test data for succesful builds ocamltest+testsuite: by default, only keep test data on failure Apr 2, 2020
@gasche
Copy link
Member Author

gasche commented Apr 2, 2020

Duh. Thanks!

(cc also @dra27 who has weird testcases in mind that copy and generate data in interesting ways, and might have a different opinion on the right default.)

@shindere
Copy link
Contributor

shindere commented Apr 2, 2020

I very much like the idea, thanks a lot, @gasche.

Regarding the coding details:

  • It may be better to stick to OCAMLTESTFLAGS (without an _) rather thn
    renaming to OCAMLTEST_FLAGS

  • Regarding the name of the option, I'd suggest -keep-test-dir-on-success
    which seems more precise to me

  • Presently, the PR somehow hardcodes the link between test result and
    summaries, e.g. a skipped test is considered not being a failure hence
    its directory would be removed, but this is something the user may want
    to control. I'm not necessarily saying the code should be further
    extended in the present PR, just thinking aloud here to collect
    others' opinions.

  • In the same vein, the ocamltest option could actually be seen as a level.
    It could take the values all, skipped and failed to also cover the
    situation described above (skipped would mean to keep both skipped and
    failed tests, failed would mean to keep only the failed ones).

  • Regarding KEEP_DATA_ON_SUCCESS: i'd rename to something like
    KEEP_TESTDIR_ON_SUCCESS. It would seem nice to me to include
    TEST in the variable name in case we would want to
    also make it available from the main Makefile. In such a context,
    the name would, I think, become more self-explanatory.

@gasche
Copy link
Member Author

gasche commented Apr 2, 2020

I'm not convinced by the idea of parametrization. In particular I don't see any situation where you would want to keep data for skipped tests (especially as, a priori, skipped tests did not run, so there should not be any data worth keeping). I would propose to wait until we see a clear need for it before making the interface more complex.

I will apply your renaming suggestions, expect that the variable will be KEEP_TEST_DIR_ON_SUCCESS (with an extra _) so that there is a direct mapping from the ocamltest variable for convenience/discoverability.

@gasche
Copy link
Member Author

gasche commented Apr 2, 2020

And: Thanks for the reviews!

@shindere
Copy link
Contributor

shindere commented Apr 2, 2020 via email

@gasche
Copy link
Member Author

gasche commented Apr 2, 2020

One question I think (for @shindere and @dra27) is whether we want to use the same default on the CI machines -- drop test data on successes -- or whether in that setting it is better to, when we inspect the output of a failed CI run, have all the gibibytes available. If the latter, then we want to set KEEP_..._ON_SUCCESS in the CI scripts.

@shindere
Copy link
Contributor

shindere commented Apr 2, 2020 via email

The existing approach requires to set all ocamltest flags at once on
recursive calls. This is very inconvenient if we want to set more than
one flag -- we wish to support choosing both -promote
and -keep-test-dir-on-success.
On my machine, running the whole testsuite generates 1.5Gio of test
data. I have 11 workdirs for the OCaml repository (versions from 4.08
to trunk, plus several experimental workdirs); at any point in time
there can be more than a dozen gibibytes of test data on my disk, and
this is too much.

I use the test data saved by ocamltest when a test fails, to diagnose
the failure. I don't remember ever looking at the test data of
a succesful test.

The present patchset changes ocamltest to, by default, discard the
test directory of succesful tests -- the test artefacts are kept only
when there is a failure.

If one wishes to preserve the test data of succesful tests, one should
explicitly pass the -keep-test-dir-on-success flag. The
testsuite/Makefile is then changed to pass this flag if the user set
the KEEP_TEST_DIR_ON_SUCCESS variable to a non-empty value.
@gasche gasche force-pushed the testsuite-drop-passed-artefacts branch from f8f897f to 86066c8 Compare April 2, 2020 14:24
@gasche
Copy link
Member Author

gasche commented Apr 2, 2020

I rebased the PR with the renamings.

@shindere
Copy link
Contributor

shindere commented Apr 2, 2020 via email

@gasche gasche merged commit b97f817 into ocaml:trunk Apr 2, 2020
@gasche
Copy link
Member Author

gasche commented Apr 2, 2020

Merged, thanks!

@xavierleroy
Copy link
Contributor

xavierleroy commented Apr 7, 2020

We have new warnings reported by "make", and I think this PR is responsible for it:

Running tests from 'tests/typing-extensions' ...
Makefile:65: warning: undefined variable 'PROMOTE'
Makefile:71: warning: undefined variable 'KEEP_TEST_DIR_ON_SUCCESS'

Please add "define if not defined" assignments in the right places:

PROMOTE ?=
KEEP_TEST_DIR_ON_SUCCESS ?=

This is also the right place to add a comment explaining when we expect those variables to be set on the "make" command-line.

@gasche
Copy link
Member Author

gasche commented Apr 7, 2020

Guilty! (I don't think that we want to let users set the first variable, so I will just use =; they should use make promote to explicitly require test promotion.)

@gasche
Copy link
Member Author

gasche commented Apr 7, 2020

The parentheses above reveal that I'm still not very knowledgeable about how Make works; I would like the variable to be empty when the user invokes make (and ideally avoid pollution from the unix environment if there is a PROMOTE there), but recursive calls should use the setting passed at the recursive call-site. I'll play with an example to find out.

@gasche
Copy link
Member Author

gasche commented Apr 7, 2020

Testing indicates that setting PROMOTE= in the makefile will be overriden by explicit setting the make environment at invocation time (either by the user or recursively; so it has the correct semantics in the recursive call), but will override a setting from the unix environment (so name conflicts are avoided). This is exactly what I want for PROMOTE, whereas ?= is the right choice for KEEP_TEST_DIR_ON_SUCCESS, which we want to let the user override.

@gasche
Copy link
Member Author

gasche commented Apr 7, 2020

I went to the GNU make documentation and found out there is also override PROMOTE = foo which ignores invocation-time settings. The semantics of make variables is so exciting!

@shindere
Copy link
Contributor

shindere commented Apr 7, 2020 via email

gasche added a commit that referenced this pull request Apr 7, 2020
@gasche
Copy link
Member Author

gasche commented Apr 7, 2020

Fixed in 7612a6d, thanks.

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.

None yet

4 participants