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

Rewrite tests #478

Merged
merged 4 commits into from
Jul 31, 2022
Merged

Rewrite tests #478

merged 4 commits into from
Jul 31, 2022

Commits on Jul 30, 2022

  1. Rewrite tests

    This rewrites quite a lot of tests to be much more easily readable.
    
    While working on #472 I wanted to check "how do renames behave now?",
    and found this quite hard as most test cases were >90% "plumbing", and
    seeing "what file operations does this do?" and "what events do we get?"
    was not very easy.
    
    So refactor the lot, based on some work I did in #472:
    
    - Add a bunch of "shell-like" helper functions so you're not forever
      typing error checks, filepath.Join(), and eventSeparator(). Just
      touch(t, tmp, "file") will create a file in tmp.
    
    - Add eventCollector type which will collect all events in in a slice,
      replacing the previous "counter". This also ensures that the Watcher
      is closed within a second (this removes a lot of duplicate code).
    
      This is also much more precise than merely counting events; before
      random events could get emitted but if you weren't counting those then
      you'd never know.
    
      Downside is that some tests are a bit more flaky now as some
      behaviours are not always consistent in various edge cases; these are
      pre-existing bugs.
    
    - Add Events (plural) type (only for tests), and helper function to
      create this from a string like:
    
          REMOVE  /link
          CREATE  /link
          WRITE   /link
    
      Which makes seeing which events are received, diffing them, etc. much
      easier.
    
    - Add Parallel() for most tests; reduces runtime on my system from ~12
      seconds to ~6 seconds.
    
    All in all it reduces the integrations_test.go from 1279 lines to 405
    lines and it's quite easy to see which events are expected for which
    operations, which should make things a lot easier going forward.
    arp242 committed Jul 30, 2022
    Configuration menu
    Copy the full SHA
    ef700af View commit details
    Browse the repository at this point in the history
  2. Also skip this test on NetBSD

    arp242 committed Jul 30, 2022
    Configuration menu
    Copy the full SHA
    1a61c44 View commit details
    Browse the repository at this point in the history
  3. I am an idiot

    arp242 committed Jul 30, 2022
    Configuration menu
    Copy the full SHA
    a9c46d1 View commit details
    Browse the repository at this point in the history
  4. Use filepath.ToSlash()

    arp242 committed Jul 30, 2022
    Configuration menu
    Copy the full SHA
    33b74ce View commit details
    Browse the repository at this point in the history