diff --git a/modules/nextflow/src/main/groovy/nextflow/trace/TraceRecord.groovy b/modules/nextflow/src/main/groovy/nextflow/trace/TraceRecord.groovy index 33c4a5d510..fad84b9625 100644 --- a/modules/nextflow/src/main/groovy/nextflow/trace/TraceRecord.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/trace/TraceRecord.groovy @@ -418,48 +418,50 @@ class TraceRecord implements Serializable { */ TraceRecord parseTraceFile( Path file ) { + try (BufferedReader reader = new BufferedReader(new FileReader(file.toFile()))) { - final text = file.text - - final lines = text.readLines() - if( !lines ) - return this - if( lines[0] != 'nextflow.trace/v2' ) - return parseLegacy(file, lines) - - for( int i=0; i @@ -37,6 +42,9 @@ class TraceFileObserverTest extends Specification { final static long MB = 1024 * 1024 + @TempDir + Path tempDir + def setupSpec() { TraceRecord.TIMEZONE = TimeZone.getTimeZone('UTC') // note: set the timezone to be sure the time string does not change on CI test servers } @@ -235,7 +243,7 @@ class TraceFileObserverTest extends Specification { given: final KB = 1024L - final file = TestHelper.createInMemTempFile('trace') + final file = Files.createTempFile(tempDir,'trace', '.txt') file.text = ''' pid state %cpu %mem vmem rss peak_vmem peak_rss rchar wchar syscr syscw read_bytes write_bytes 18 0 7999 46 7868980 6694900 7876620 6702144 2147483647 2147483647 44001533 148401890 2147483647 2147483647 diff --git a/modules/nextflow/src/test/groovy/nextflow/trace/TraceRecordTest.groovy b/modules/nextflow/src/test/groovy/nextflow/trace/TraceRecordTest.groovy index f30d2c7d8f..af156ce0a1 100644 --- a/modules/nextflow/src/test/groovy/nextflow/trace/TraceRecordTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/trace/TraceRecordTest.groovy @@ -18,9 +18,13 @@ package nextflow.trace import groovy.json.JsonSlurper import spock.lang.Specification +import spock.lang.TempDir import spock.lang.Unroll import test.TestHelper +import java.nio.file.Files +import java.nio.file.Path + /** * * @author Paolo Di Tommaso @@ -33,6 +37,9 @@ class TraceRecordTest extends Specification { TraceRecord.TIMEZONE = TimeZone.getTimeZone('UTC') // note: set the timezone to be sure the time string does not change on CI test servers } + @TempDir + Path tempDir + def 'test get field'() { given: @@ -153,7 +160,7 @@ class TraceRecordTest extends Specification { def 'should parse a trace file and return a TraceRecord object'() { given: - def file = TestHelper.createInMemTempFile('trace') + def file = Files.createTempFile(tempDir,'trace', '.txt') file.text = '''\ nextflow.trace/v2 realtime=12021 @@ -200,7 +207,7 @@ class TraceRecordTest extends Specification { def 'should parse a legacy trace file and return a TraceRecord object'() { given: - def file = TestHelper.createInMemTempFile('trace') + def file = Files.createTempFile(tempDir,'trace', '.txt') file.text = ''' pid state %cpu %mem vmem rss peak_vmem peak_rss rchar wchar syscr syscw read_bytes write_bytes 1 0 10 20 11084 1220 21084 2220 4790 12 11 1 20 30