@@ -121,64 +121,51 @@ class AnsiLogObserverTest extends Specification {
121121 AnsiLogObserver . hyperlink(' text' , ' ' ) == ' text'
122122 }
123123
124- @Unroll
125- def ' should render a process line with workDir hyperlink' () {
126-
124+ def ' should render hash as hyperlink when workDir is set' () {
127125 given :
128126 def session = Mock (Session ) { getConfig() >> [cleanup : false ] }
129127 def observer = new AnsiLogObserver ()
130128 observer. @session = session
129+ observer. @labelWidth = 3
130+ observer. @cols = 190
131+ and :
131132 def stats = new ProgressRecord (1 , ' foo' )
132- stats. submitted = SUBMIT
133- stats. succeeded = SUCCEEDED
134- stats. hash = HASH
133+ stats. submitted = 1
134+ stats. hash = ' 4e/486876'
135135 stats. workDir = WORKDIR
136136
137137 when :
138- observer. @labelWidth = stats. name. size()
139- observer. @cols = 190
138+ def result = observer. line(stats). toString()
140139
141140 then :
142- // Strip ANSI color codes but preserve OSC 8 hyperlink sequences
143- def result = observer. line(stats). toString()
144- def strippedColors = result. replaceAll(' \u 001B\\ [[\\ d;]*[^\\ d;]' ,' ' )
145- strippedColors. contains(HASH_DISPLAY )
146- // Check hyperlink is present when workDir is set
147- if ( WORKDIR ) {
148- assert result. contains(' \0 33]8;;' + EXPECTED_HREF + ' \0 07' )
149- assert result. contains(' \0 33]8;;\0 07' )
150- }
141+ result. contains(' \0 33]8;;' + EXPECTED_HREF + ' \0 07' )
142+ result. contains(' \0 33]8;;\0 07' )
151143
152144 where :
153- HASH | WORKDIR | SUBMIT | SUCCEEDED | HASH_DISPLAY | EXPECTED_HREF
154- ' 4e/486876' | ' /work/4e/486876abc' | 1 | 0 | ' 4e/486876' | ' file:///work/4e/486876abc'
155- ' 4e/486876' | ' s3://bucket/work/4e/486876abc' | 0 | 1 | ' 4e/486876' | ' s3://bucket/work/4e/486876abc'
156- ' 4e/486876' | null | 1 | 0 | ' 4e/486876' | null
157- null | null | 0 | 0 | ' -' | null
145+ WORKDIR | EXPECTED_HREF
146+ ' /work/4e/486876abc' | ' file:///work/4e/486876abc'
147+ ' s3://bucket/work/4e/486876abc' | ' s3://bucket/work/4e/486876abc'
158148 }
159149
160150 def ' should not render hyperlink when cleanup is enabled' () {
161-
162151 given :
163152 def session = Mock (Session ) { getConfig() >> [cleanup : true ] }
164153 def observer = new AnsiLogObserver ()
165154 observer. @session = session
155+ observer. @labelWidth = 3
156+ observer. @cols = 190
157+ and :
166158 def stats = new ProgressRecord (1 , ' foo' )
167159 stats. submitted = 1
168160 stats. hash = ' 4e/486876'
169161 stats. workDir = ' /work/4e/486876abc'
170162
171163 when :
172- observer. @labelWidth = stats. name. size()
173- observer. @cols = 190
174164 def result = observer. line(stats). toString()
175165
176166 then :
177- // Should NOT contain hyperlink escape sequences
167+ // Should NOT contain hyperlink start sequence
178168 ! result. contains(' \0 33]8;;' )
179- ! result. contains(' \0 07' )
180- // But should still contain the hash
181- result. replaceAll(' \u 001B\\ [[\\ d;]*[^\\ d;]' ,' ' ). contains(' 4e/486876' )
182169 }
183170
184171}
0 commit comments