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

ogma-core: Fix missing stream name substitution. Refs #120. #123

Merged
merged 2 commits into from
Jan 24, 2024

Conversation

ivanperez-keera
Copy link
Member

Use the same name substitution when generating trigger calls in Spec2Copilot, as prescribed in the solution proposed for #120.

When using property names as arguments to trigger, the Spec2Copilot
backend does not apply the same variable/name substitution that was
applied in their definition, thus referring in the call to trigger to an
undefined argument.

This commit modifies the generation of trigger names in Copilot to be
able to apply the same name subsitution map, so that the stream name is
resolved.
@ivanperez-keera ivanperez-keera marked this pull request as ready for review January 24, 2024 09:53
@ivanperez-keera
Copy link
Member Author

ivanperez-keera commented Jan 24, 2024

Change Manager: Verified that:

  • Solution is implemented:
    • The code proposed compiles passes the tests. Details:
      Docker image:

      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
      RUN apt-get install --yes git
      
      # We install the application first and then test it, in case any tests need to
      # run the tool.
      CMD git clone $REPO && \
          cd $NAME && \
          git checkout $COMMIT && \
          cd .. && \
          cabal v1-install $NAME/ogma-cli/ $NAME/ogma-core/ --enable-tests --constraint "ogma-language-fret-reqs -test" && \
          cabal v1-install $NAME/ogma-cli/ $NAME/ogma-core/ --enable-tests --constraint "ogma-language-fret-reqs -test" --run-tests -j1

      Command:

      $ docker run -e "REPO=https://github.com/nasa/ogma" -e "NAME=ogma" -e PAT="ogma-" -e "COMMIT=448465b5d5bdbb4d62f051d7a27a475e1bdbc417" -it ogma-test
    • The solution proposed fixes the issues described. Details:
      The following Dockerfile checks that the given given backend produces a Copilot spec that compiles, in which case it prints the message "Success".

      --- Dockerfile
      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
      RUN apt-get install --yes git
      
      ADD sample.json /tmp/
      
      RUN cabal v1-install BNFC copilot-3.18.1
      
      # We install the application first and then test it, in case any tests need to
      # run the tool.
      CMD git clone $REPO && \
          cd $NAME && \
          git checkout $COMMIT && \
          cd .. && \
          cabal v1-install $NAME/$PAT**/ && \
          ogma fret-component-spec --fret-file-name /tmp/sample.json > sample.hs && \
          cabal v1-exec -- runhaskell sample.hs && \
          echo "Success"
      
      -- sample.json
      {
        "RTSASpec": {
          "Internal_variables": [],
          "Other_variables": [
            {"name":"param", "type":"bool"}
          ],
          "Requirements": [
            {
              "name": "one",
              "CoCoSpecCode": "true",
              "ptLTL": "((H (param) ))",
              "fretish": "Meaning not specified"
            }
          ]
        }
      }

      Command:

      $ docker run -e "REPO=https://github.com/nasa/ogma" -e "NAME=ogma" -e PAT="ogma-" -e "COMMIT=448465b5d5bdbb4d62f051d7a27a475e1bdbc417" -it ogma-verify-120
      
  • Implementation is documented. Details:
    No changes needed.
  • Change history is clear.
  • Commit messages are clear.
  • Changelogs are updated.
  • Examples are updated. Details:
    No examples affected.
  • Required version bumps are evaluated. Details:
    Bump not needed (bug fix to comply with intended API).

@ivanperez-keera ivanperez-keera merged commit e630e06 into develop Jan 24, 2024
@ivanperez-keera ivanperez-keera deleted the develop-fix-triggerStreamName branch January 24, 2024 11:56
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

Successfully merging this pull request may close these issues.

1 participant