Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop-format-localfile' into develop. Close #200.
**Description** Ogma allows users to select the format used for the JSON file, but only known formats can be selected. Users should be able to pass a local file containing a JSON format specification as an argument. **Type** - Feature: new capability. **Additional context** None. **Requester** - Ivan Perez. **Method to check presence of bug** Not applicable (not a bug). **Expected result** Users can provide a file as JSON format specification as argument. The following dockerfile checks that a known format can still be used, and that, if a custom provided format is specified in the command line, it is picked up instead and used to parse the input file, in both cases checking also that the resulting monitor compiles successfully, after which it prints the message "Success": ``` --- Dockerfile-verify-200 FROM ubuntu:trusty RUN apt-get update RUN apt-get install --yes software-properties-common RUN add-apt-repository ppa:hvr/ghc RUN apt-get update RUN apt-get install --yes ghc-8.6.5 cabal-install-2.4 RUN apt-get install --yes libz-dev ENV PATH=/opt/ghc/8.6.5/bin:/opt/cabal/2.4/bin:$PWD/.cabal-sandbox/bin:$PATH RUN cabal update RUN cabal v1-sandbox init RUN cabal v1-install alex happy --constraint='happy < 2.0' RUN apt-get install --yes git ADD json-custom-format /tmp/json-custom-format ADD properties.json /tmp/properties.json CMD git clone $REPO && \ cd $NAME && \ git checkout $COMMIT && \ cd .. && \ cabal v1-install copilot-4.2 $NAME/$PAT**/ && \ ogma standalone --input-format fdb --file-name $NAME/ogma-cli/examples/DB.json --target-dir output1 && \ cabal v1-exec -- runhaskell -XPartialTypeSignatures -Wno-partial-type-signatures output1/Copilot.hs && \ ogma standalone --input-format /tmp/json-custom-format --file-name /tmp/properties.json --target-dir output2 && \ cabal v1-exec -- runhaskell output2/Copilot.hs && \ echo "Success" --- json-custom-format JSONFormat { specInternalVars = Just "..internal_vars[*]" , specInternalVarId = ".name" , specInternalVarExpr = ".meaning" , specInternalVarType = Just ".type" , specExternalVars = Just "..other_vars[*]" , specExternalVarId = ".name" , specExternalVarType = Just ".type" , specRequirements = "..requirements[*]" , specRequirementId = ".id" , specRequirementDesc = Just ".text" , specRequirementExpr = ".formula" } -- properties.json { "spec": { "internal_vars": [], "other_vars": [ {"name":"param", "type":"bool"} ], "requirements": [ { "id": "req001", "formula": "(H param)", "text": "param is always true" } ] } } ``` Command (substitute variables based on new path after merge): ```sh $ docker run -e "REPO=https://github.com/NASA/ogma" -e "NAME=ogma" -e "PAT=ogma" -e "COMMIT=<HASH>" -it ogma-verify-200 ``` **Solution implemented** `ogma-core` now checks if the file format name provided exists as a local file, or if, judging by the name, it refers to a local file. Otherwise, Ogma finds the file in the package's data directory. If neither can be found, Ogma prints an error message telling the user that the file cannot be found, and giving the file name it attempted to access. **Further notes** None.
- Loading branch information