Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null Items Dropped From Lists When Returning From Process Tests #226

Open
emarinier opened this issue Jul 5, 2024 · 0 comments
Open

Null Items Dropped From Lists When Returning From Process Tests #226

emarinier opened this issue Jul 5, 2024 · 0 comments

Comments

@emarinier
Copy link

emarinier commented Jul 5, 2024

When I try to test that a null value can be returned within a list from a process, it appears that nf-test is dropping the null values from the list. I've created the following example to demonstrate the problem:

main.nf

include { return_null } from './return_null.nf'

workflow {
    return_null | view { it }
}

return_null.nf

process return_null {

    output:
    val null_list, emit: null_list

    exec:
    null_list = ["0", "1", "", null, "4"]
}

return_null.nf.test

nextflow_process {

    name "Test Process return_null"
    script "return_null.nf"
    process "return_null"

    test("Should run without failures") {

        when {
            params {}
            process {}
        }

        then {
            assert process.success

            with(process.out) {
                assert null_list == [["0", "1", "", null, "4"]]
            }
        }

    }

}

Nextflow seems to support this behaviour:

$ nextflow run main.nf 
N E X T F L O W  ~  version 23.04.3
Launching `main.nf` [agitated_kimura] DSL2 - revision: 7bdd792613
executor >  local (1)
[dd/20ca57] process > return_null [100%] 1 of 1 ✔
[0, 1, , null, 4]

However, nf-test does not seem to support it:

$ nf-test test

🚀 nf-test 0.8.2
https://code.askimed.com/nf-test
(c) 2021 - 2023 Lukas Forer and Sebastian Schoenherr

Found 1 files in test directory.

Test Process return_null

  Test [36f973af] 'Should run without failures' FAILED (3.857s)

  Assertion failed: 
  
  assert null_list == [["0", "1", "", null, "4"]]
         |         |
         |         false
         [['0', '1', '', '4']]
  
  Nextflow stdout:
  
  Nextflow stderr:
  
  



FAILURE: Executed 1 tests in 3.862s (1 failed)

I'm not familiar with the nf-test project, but I dug around a bit, and my best guess is that during JSON serialization of the channel (here), a JsonGenerator object is used with the .excludeNulls() option set (here). The corresponding outputs in meta/output_0.json and meta/output_null_list.json have the null item missing, so it seems to be related to serialization:

{"null_list":[["0","1","","4"]]}

Anyways, I'm not sure what the expected behaviour for nf-test is supposed to be, but I thought I would mention it here, since it seems to be different than Nextflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant