-
Notifications
You must be signed in to change notification settings - Fork 338
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
Ability to filter with case insensitive tags #2039
Conversation
Signed-off-by: Haroon Sheikh <haroon.sheikh@sky.uk>
Signed-off-by: Haroon Sheikh <haroon.sheikh@sky.uk>
Signed-off-by: Haroon Sheikh <haroon.sheikh@sky.uk>
@@ -70,7 +70,7 @@ func sanitize(tag string) string { | |||
if _, err := strconv.ParseBool(tag); err == nil { | |||
return fmt.Sprintf("{%s}", tag) | |||
} | |||
return tag | |||
return strings.ToLower(tag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @haroon-sheikh can we add a new property to make this a configuration? By default it's case sensitive with the option to turn it off. Worth observing if anyone uses case sensitive tag and making case insensitivity the default option in a future release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only concern is, if we turn it off by default then its very unlikely to be used by others and we'll never find out if they're using it in a case sensitive way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've now added a flag around it. Let me know what you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. We can turn it on by default. Will take a look at the PR soon.
Signed-off-by: Haroon Sheikh <haroon.sheikh@sky.uk>
Signed-off-by: Haroon Sheikh <haroon.sheikh@sky.uk>
Signed-off-by: Haroon Sheikh <haroon.sheikh@sky.uk>
env/env.go
Outdated
@@ -38,6 +38,7 @@ const ( | |||
saveExecutionResult = "save_execution_result" | |||
// CsvDelimiter holds delimiter used to parse csv files | |||
CsvDelimiter = "csv_delimiter" | |||
allowCaseInSensitiveTags = "allow_case_insensitive_tags" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For readabioity better to call this
allowCaseInSensitiveTags = "allow_case_insensitive_tags" | |
allowCaseSensitiveTags = "allow_case_sensitive_tags" |
And set it as false by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
env/env.go
Outdated
@@ -115,6 +116,7 @@ func loadDefaultEnvVars() { | |||
defaultScreenshotDir := filepath.Join(config.ProjectRoot, common.DotGauge, "screenshots") | |||
addEnvVar(GaugeScreenshotsDir, defaultScreenshotDir) | |||
addEnvVar(gaugeSpecFileExtensions, ".spec, .md") | |||
addEnvVar(allowCaseInSensitiveTags, "false") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addEnvVar(allowCaseInSensitiveTags, "false") | |
addEnvVar(allowCaseISensitiveTags, "false") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
env/env.go
Outdated
@@ -309,3 +311,8 @@ var GaugeSpecFileExtensions = func() []string { | |||
} | |||
return allowedExts | |||
} | |||
|
|||
// AllowCaseInSensitiveTags determines if the casing is ignored in tags filtering | |||
var AllowCaseInSensitiveTags = func() bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var AllowCaseInSensitiveTags = func() bool { | |
var AllowCaseISensitiveTags = func() bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
env/env_test.go
Outdated
@@ -39,6 +39,7 @@ func (s *MySuite) TestLoadDefaultEnv(c *C) { | |||
defaultScreenshotDir := filepath.Join(config.ProjectRoot, common.DotGauge, "screenshots") | |||
c.Assert(os.Getenv("gauge_screenshots_dir"), Equals, defaultScreenshotDir) | |||
c.Assert(os.Getenv("gauge_spec_file_extensions"), Equals, ".spec, .md") | |||
c.Assert(os.Getenv("allow_case_insensitive_tags"), Equals, "false") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c.Assert(os.Getenv("allow_case_insensitive_tags"), Equals, "false") | |
c.Assert(os.Getenv("allow_case_sensitive_tags"), Equals, "false") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
filter/specItemFilter.go
Outdated
@@ -70,6 +71,9 @@ func sanitize(tag string) string { | |||
if _, err := strconv.ParseBool(tag); err == nil { | |||
return fmt.Sprintf("{%s}", tag) | |||
} | |||
if env.AllowCaseInSensitiveTags() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to use AllowCaseInSensitiveTags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
filter/specItemFilter_test.go
Outdated
@@ -19,6 +20,15 @@ type MySuite struct{} | |||
|
|||
var _ = Suite(&MySuite{}) | |||
|
|||
func before() { | |||
os.Clearenv() | |||
os.Setenv("allow_case_insensitive_tags", "true") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.Setenv("allow_case_insensitive_tags", "true") | |
os.Setenv("allow_case_sensitive_tags", "true") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
version/version.go
Outdated
@@ -14,7 +14,7 @@ import ( | |||
) | |||
|
|||
// CurrentGaugeVersion represents the current version of Gauge | |||
var CurrentGaugeVersion = &Version{1, 3, 1} | |||
var CurrentGaugeVersion = &Version{1, 3, 2} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Signed-off-by: Haroon Sheikh <haroon.sheikh@sky.uk>
Thanks for fixing this! This seems to have highlighted that some specs for GoCD were not actually running as intended due to the previous case sensitivity :'( |
Unfortunately, these specs were not running before due to case sensitivity in tags in Gauge. This case sensitivity was removed in getgauge/gauge#2039 (Gauge 1.3.2+) which means these specs are now running in earlier releases.
Signed-off-by: Haroon Sheikh haroon.sheikh@outlook.com