From 5a481afe15b0ee20a09937fe75f1d7cfff0f3df6 Mon Sep 17 00:00:00 2001 From: Gunjan Vyas Date: Mon, 24 Jan 2022 19:01:17 +0530 Subject: [PATCH 1/2] Fix for file not found error message discrepancy in windows --- test/e2e/service_file_test.go | 12 +++++++++++- test/e2e/service_import_test.go | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/test/e2e/service_file_test.go b/test/e2e/service_file_test.go index 2b30717fa2..f18494d11c 100644 --- a/test/e2e/service_file_test.go +++ b/test/e2e/service_file_test.go @@ -24,6 +24,8 @@ import ( "path/filepath" "testing" + "gotest.tools/v3/assert/cmp" + "gotest.tools/v3/assert" "knative.dev/client/lib/test" @@ -124,7 +126,7 @@ func serviceCreateFromFile(r *test.KnRunResultCollector, serviceName, filePath s func serviceCreateFromFileError(r *test.KnRunResultCollector, serviceName, filePath string) { out := r.KnTest().Kn().Run("service", "create", serviceName, "--filename", filePath) r.AssertError(out) - assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stderr, "no", "such", "file", "directory", filePath)) + assert.Check(r.T(), fileNotFoundErrorCheck(out, filePath)) } func serviceCreateFromFileNameMismatch(r *test.KnRunResultCollector, serviceName, filePath string) { @@ -132,3 +134,11 @@ func serviceCreateFromFileNameMismatch(r *test.KnRunResultCollector, serviceName r.AssertError(out) assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stderr, "provided", "'"+serviceName+"'", "name", "match", "from", "file")) } + +func fileNotFoundErrorCheck(out test.KnRunResult, filePath string) cmp.Comparison { + result := util.ContainsAllIgnoreCase(out.Stderr, "no", "such", "file", "directory", filePath) + if result() == cmp.ResultSuccess { + return result + } + return util.ContainsAllIgnoreCase(out.Stderr, "system", "cannot", "find", "file", "specified", filePath) +} diff --git a/test/e2e/service_import_test.go b/test/e2e/service_import_test.go index 5f37f805d0..536c4ccfb3 100644 --- a/test/e2e/service_import_test.go +++ b/test/e2e/service_import_test.go @@ -90,5 +90,5 @@ func serviceImportExistsError(r *test.KnRunResultCollector, filename string) { func serviceImportFileError(r *test.KnRunResultCollector, filePath string) { out := r.KnTest().Kn().Run("service", "import", filePath) r.AssertError(out) - assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stderr, "no", "such", "file", "directory", filePath)) + assert.Check(r.T(), fileNotFoundErrorCheck(out, filePath)) } From 7f14d1542ee5c4ed4af3213db397c191427eca60 Mon Sep 17 00:00:00 2001 From: Gunjan Vyas Date: Mon, 24 Jan 2022 19:41:48 +0530 Subject: [PATCH 2/2] Added comment --- test/e2e/service_file_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/service_file_test.go b/test/e2e/service_file_test.go index f18494d11c..67de276174 100644 --- a/test/e2e/service_file_test.go +++ b/test/e2e/service_file_test.go @@ -140,5 +140,6 @@ func fileNotFoundErrorCheck(out test.KnRunResult, filePath string) cmp.Compariso if result() == cmp.ResultSuccess { return result } + // Check for Windows specific error message in case file is not found return util.ContainsAllIgnoreCase(out.Stderr, "system", "cannot", "find", "file", "specified", filePath) }