Long file path cause integration-test lib tests to fail
Summary
In gitlab-org/security-products/analyzers/gemnasium!639 (comment 1789618709) the following was mentioned:
Rename renames (moves) oldpath to newpath. If newpath already exists and is not a directory, Rename replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories. Even within the same directory, on non-Unix platforms Rename is not an atomic operation. If there is an error, it will be of type *LinkError.
This is caused by the file system limits. Using nested contexts or descriptive context is an important aspect of writing clear specs. We should look at a replacement for this to prevent running into this issue. Some possibilities include using:
- Use the #id instead of the
#description
. This may not be human-readable. There's no example output so testing will be needed. - Use the #location_rerun_argument instead of the
#description
. This is very useful in the context of table driven tests. - Truncate the description to a max of 255 characters. Possible collisions if the remaining characters made the file path unique.
Improvements
No limit on nested contexts or context names.
Involved components
Optional: Missing test coverage
Implementation plan
-
Add a new @output_dir
variable which creates subdirs for each rspec context and example instead of concatenating them together as the@description
var does. -
Update the spec file to use this new @output_dir
var. For example, to enable this ingemnasium
, update the gemnasium_image_spec.rb file to the following:diff --git a/spec/gemnasium_image_spec.rb b/spec/gemnasium_image_spec.rb index 06e4e88..d6870d1 100644 --- a/spec/gemnasium_image_spec.rb +++ b/spec/gemnasium_image_spec.rb @@ -58,7 +58,7 @@ describe "running image" do let(:scan) do GitlabSecure::IntegrationTest::DockerRunner.run_with_cache( - image_name, fixtures_dir, target_dir, @description, + image_name, fixtures_dir, target_dir, @output_dir, command: command, script: script, offline: offline,