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

Clean test_{runner,scalafmt_helper}, add diagnostic env vars, and improve test_cross_build performance #1646

Merged

Commits on Nov 9, 2024

  1. Clean test_{runner,scalafmt_helper}, add env vars

    Did a little cleaning up while trying to get protobuf to stop
    recompiling so often. Didn't impact that problem, but good cleanups
    regardless.
    
    Also added two environment variables to make diagnosing test failures
    (or slowdowns) easier:
    
    - Defining `RULES_SCALA_TEST_ONLY`will cause only one specific test case
      to run, with full Bazel output. This is helpful for pinpointing and
      working on a specific test without hunting for it or recreating its
      commands.
    
    - Defining `RULES_SCALA_TEST_VERBOSE` will cause all tests to emit full
      Bazel output. This is more useful when running all the tests from a
      specific script from `test/shell/test_*.sh`.
    
    Also, today I learned that `SECONDS` is a special Bash variable. Making
    it `local` screwed it up and showed all tests as taking zero seconds.
    mbland committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    2f6efef View commit details
    Browse the repository at this point in the history
  2. Don't clean test_cross_build, shutdown at end

    This speeds up the `test_cross_build.sh` tests substantially,
    particularly between runs. Here are the times for two runs before this
    change; the first is after running `bazel clean` and `bazel shutdown` in
    the `test_cross_build` directory:
    
    ```txt
    $ /usr/bin/time ./test_cross_build.sh
    
    running test test_cross_build
     Test "test_cross_build" successful (73 sec)
    running test test_scalafmt
     Test "test_scalafmt" successful (94 sec)
          167.01 real         0.37 user         0.50 sys
    
    $ /usr/bin/time ./test_cross_build.sh
    
    running test test_cross_build
     Test "test_cross_build" successful (8 sec)
    running test test_scalafmt
     Test "test_scalafmt" successful (92 sec)
           99.96 real         0.35 user         0.48 sys
    ```
    
    Here are the times for two equivalent runs after this change:
    
    ```txt
    $ /usr/bin/time ./test_cross_build.sh
    
    running test test_cross_build
     Test "test_cross_build" successful (71 sec)
    running test test_scalafmt
     Test "test_scalafmt" successful (6 sec)
           77.50 real         0.33 user         0.44 sys
    
    $ /usr/bin/time ./test_cross_build.sh
    
    running test test_cross_build
     Test "test_cross_build" successful (5 sec)
    running test test_scalafmt
     Test "test_scalafmt" successful (2 sec)
            7.21 real         0.26 user         0.38 sys
    ```
    
    The effect is even more dramatic when setting compiler flags in
    `.bazelrc`, as I've tried while building protobuf-v28.3 under Bazel
    6.5.0.
    mbland committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    4faf196 View commit details
    Browse the repository at this point in the history