Skip to content

Fix long file path bug by storing output in subdirs

Adam Cohen requested to merge add-path-to-file-variable into main

What does this MR do?

This MR fixes a bug which would result in file system errors caused by pathnames that exceeded the operating system maximum length. This bug has been resolved by adding a new @output_dir instance variable to the spec_helper.rb file.

Before this fix, the @description instance var generated path names by concatenating the rspec context and example names, which resulted in directory names such as when-scanning-go-modules-behaves-like-successful-scan-creates-a-report. However, in some instances, the path name would exceed the maximum length allowed by the operating system and cause an error.

When the @output_dir var is used instead of the @description var, the behaviour is altered, and instead of concatenating together the rspec context and example names, we create subdirs, which avoids the long path error:

old behaviour:

.
└── tmp/
    └── test-1234/
        └── go-modules/
            └── default/
                └── when-scanning-go-modules-behaves-like-successful-scan-creates-a-report

Max filename length: 70

new behaviour:

.
└── tmp/
    └── test-1234/
        └── go-modules/
            └── default/
                └── when-scanning-go-modules/
                    └── behaves-like-successful-scan/
                        └── creates-a-report/

Max filename length: 28

What are the relevant issue numbers?

Long file path cause integration-test lib tests... (gitlab-org/gitlab#443847 - closed) • Adam Cohen • 16.11

Edited by Adam Cohen

Merge request reports