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

Move required fields to the top and discouraged options to the bottom of fstest.FSOptions #46

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions fstest/fstest.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,25 @@ import (

// FSOptions contains required and optional settings for running fstest against your FS.
type FSOptions struct {
// Name of this test run. Required.
Name string
// TestFS sets up the current sub-test and returns an FS. Required if SetupFS is not set.
// Must support running in parallel with other tests. For a global FS like 'osfs', return a sub-FS rooted in a temporary directory for each call to TestFS.
// Cleanup should be run via tb.Cleanup() tasks.
TestFS func(tb testing.TB) SetupFS

// Setup returns an FS that can prepare files and a commit function. Required of TestFS is not set.
// When commit is called, SetupFS's changes must be copied into a new test FS (like TestFS does) and return it.
//
// In many cases, this is not needed and all preparation can be done with only the TestFS() option.
// However, in more niche file systems like a read-only FS, it is necessary to commit files to a normal FS, then copy them into a read-only store.
Setup TestSetup

// TestFS sets up the current sub-test and returns an FS. Required if SetupFS is not set.
// Must support running in parallel with other tests. For a global FS like 'osfs', return a sub-FS rooted in a temporary directory for each call to TestFS.
// Cleanup should be run via tb.Cleanup() tasks.
TestFS func(tb testing.TB) SetupFS
// Contraints limits tests to a reduced set of assertions. Avoid setting any of these options.
// For example, setting FileModeMask limits FileMode assertions on a file's Stat() result.
//
// NOTE: This MUST NOT be used lightly. Any custom constraints severely impairs the quality of a standardized file system.
Constraints Constraints

// ShouldSkip determines if the current test with features defined by 'facets' should be skipped.
// ShouldSkip() is intended for handling undefined behavior in existing systems outside one's control.
Expand All @@ -30,15 +38,6 @@ type FSOptions struct {
ShouldSkip func(facets Facets) bool

skippedTests *sync.Map // type: Facets -> struct{}

// Name of this test run. Required.
Name string

// Contraints limits tests to a reduced set of assertions. Avoid setting any of these options.
// For example, setting FileModeMask limits FileMode assertions on a file's Stat() result.
//
// NOTE: This MUST NOT be used lightly. Any custom constraints severely impairs the quality of a standardized file system.
Constraints Constraints
}

// SetupFS is an FS that supports the baseline interfaces for creating files/directories and changing their metadata.
Expand Down