Skip to content
This repository has been archived by the owner on Dec 2, 2021. It is now read-only.

Type fix for application statements/execution_file #3

Merged
merged 10 commits into from
Sep 22, 2021

Conversation

zhubonan
Copy link
Contributor

This is a great package for building CLI tools!

But, I have received this error when building an application (on Julia 1.6.1):

┌ Info: application options: 
│   options.application =
│    ComoniconOptions.Application(;
│        filter_stdlibs = false,
│        precompile = ComoniconOptions.Precompile(;
│            execution_file = ["test/runtest.jl"],
│        ),
└    )
ERROR: LoadError: TypeError: in keyword argument precompile_statements_file, expected Union{String, Vector{String}}, got a value of type Vector{Union{Nothing, String}}
Stacktrace:
 [1] build_application(m::Module, options::ComoniconOptions.Comonicon)
   @ ComoniconBuilder ~/.julia/packages/ComoniconBuilder/I9tvS/src/build.jl:59
 [2] install(m::Module, options::ComoniconOptions.Comonicon)
   @ ComoniconBuilder ~/.julia/packages/ComoniconBuilder/I9tvS/src/install.jl:66
 [3] #install#1

I think the problem is that the following lines:

exec_file = map(x -> pkgdir(m, x), options.application.precompile.execution_file)
stmt_file = map(x -> pkgdir(m, x), options.application.precompile.statements_file)

results an Array that can contain nothing. The nothing element should be filtered out instead. It works about replacing them with:

The change in this PR should make sure the type is Vector{String} instead of Vector{Union{Nothing, String}} in the same way it is for the system image function.

One more thing, if any of the files listed is missing the error would be raised inside the array comprehension.
Perhaps it is better to explicitly check for the existence of nothing and warn its implication (e.g. one of the files do not exist) to the user?

Ensure that exec_file, stmt_file arrays have the type Array{String}.
@codecov
Copy link

codecov bot commented Sep 21, 2021

Codecov Report

Merging #3 (50a1144) into master (22e532e) will increase coverage by 1.01%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #3      +/-   ##
==========================================
+ Coverage   39.77%   40.79%   +1.01%     
==========================================
  Files           4        4              
  Lines         269      277       +8     
==========================================
+ Hits          107      113       +6     
- Misses        162      164       +2     
Impacted Files Coverage Δ
src/build.jl 40.93% <0.00%> (+1.67%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 22e532e...50a1144. Read the comment docs.

@Roger-luo
Copy link
Collaborator

thanks! good catch, I think it should instead return a String[] if no file is specified instead of adding type assertions? we don't have any type inference problem here

@zhubonan
Copy link
Contributor Author

I see, then it is probably better to do array comprehension directly with String[] so the type is always Vector{String}.

It is under the Comonicon module
@Roger-luo
Copy link
Collaborator

thanks! could you also put a test case for this?

@Roger-luo
Copy link
Collaborator

just realize github has this annoying CI approve thing, great job! let's just wait for CI to pass!

@zhubonan
Copy link
Contributor Author

zhubonan commented Sep 22, 2021

seems there is an issue while building the app against the latest nightly build (segfault...). @Roger-luo Maybe the build test should be limited to the latest release for now?

@Roger-luo
Copy link
Collaborator

Yeah let's ignore the nightly for now

@Roger-luo
Copy link
Collaborator

LGTM thanks

@Roger-luo Roger-luo merged commit a2df4de into comonicon:master Sep 22, 2021
@zhubonan
Copy link
Contributor Author

No problem!
Seems that the CI still shows the failed state - I was not able to get my head around GitHub action 😂 I will leave that to you 😏
Maybe worth making a bug fix release?

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

Successfully merging this pull request may close these issues.

2 participants