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

Migrate "basic" system tests of lobster-json #153

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ integration-tests: packages

system-tests:
mkdir -p docs
make -B -C tests-system TOOL=lobster-json
make -B -C tests-system TOOL=lobster-trlc
make -B -C tests-system TOOL=lobster-python
make -B -C tests-system/lobster-json

unit-tests:
coverage run -p \
Expand Down
16 changes: 10 additions & 6 deletions lobster/tools/json/requirements.trlc
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package json_req
import req

req.Software_Requirement Dummy_Requirement {
req.Software_Requirement Synthetic_Tag_Name {
description = '''
This is not really a requirement. It will be used only to generate a minimal tracing report for each tool.
It can be deleted as soon as all the tools get their real requirements.
If the command line option --name-attribute is not given, then the tool shall create
a synthetic tag name based on the path of the JSON input file and an item counter.

Note: The item counter does not need to be unique across files.
It shall be unique at least for each input file separately.
'''
}

req.Software_Requirement Dummy_Requirement_Unit_Test {
req.Software_Requirement Name_Attribute {
description = '''
This is not really a requirement. It will be used only to generate a minimal tracing report for each tool.
It can be deleted as soon as all the tools get their real requirements.
If the command line option --name-attribute is given, then the tool shall
- use the value of the command line argument as JSON key of the JSON item
- and use that obtained value as LOBSTER item tag name.
'''
}
1 change: 1 addition & 0 deletions tests-system/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!**/expected-output/*
15 changes: 0 additions & 15 deletions tests-system/lobster-json/Makefile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
lobster-json: wrote 6 items to basic.lobster
==========
{
"data": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lobster-json: wrote 6 items to output.lobster
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--single
--tag-attribute=tags
--name-attribute=name
--out=output.lobster
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// --tag-attribute=tags
[
{
"name" : "Test_1",
Expand Down
22 changes: 22 additions & 0 deletions tests-system/lobster-json/rbt-synthetic-tag-name/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
If the `--name-attribute` option is not specified,
then the tag name must be constructed based on the following two values:
- path of the json file
- item counter

# Test case "flat-input-structure"
- No files or directories are specified.
The tool is expected to search for input files in the current working directory.
- `--name-attribute` is not given.
The tool is expected to construct LOBSTER item tags by taking the file name and
appending an integer counter, starting at 1.
This is implemented inside function `syn_test_name`, and it must handle all file
paths as relative paths, because no input files were given explicitly.
- `--out` is specified.
The tool is expected to use that path name for the output file.
- `--single` is specified to make the tool output predictable.

# Test case "nested-input-structure"
This is the same as the above test, except that its input file is nested in a
sub-sub-directory.
The tool is expected to take the names of the sub-directories into account when
generating te tag name.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
lobster-json: wrote 6 items to basic2.lobster
==========
{
"data": [
{
"tag": "json ./basic2.json:basic2.1",
"tag": "json ./basic.json:basic.1",
"location": {
"kind": "file",
"file": "./basic2.json",
"file": "./basic.json",
"line": null,
"column": null
},
"name": "./basic2.json:basic2.1",
"name": "./basic.json:basic.1",
"messages": [],
"just_up": [],
"just_down": [],
Expand All @@ -23,14 +21,14 @@ lobster-json: wrote 6 items to basic2.lobster
"status": null
},
{
"tag": "json ./basic2.json:basic2.2",
"tag": "json ./basic.json:basic.2",
"location": {
"kind": "file",
"file": "./basic2.json",
"file": "./basic.json",
"line": null,
"column": null
},
"name": "./basic2.json:basic2.2",
"name": "./basic.json:basic.2",
"messages": [],
"just_up": [],
"just_down": [],
Expand All @@ -40,14 +38,14 @@ lobster-json: wrote 6 items to basic2.lobster
"status": null
},
{
"tag": "json ./basic2.json:basic2.3",
"tag": "json ./basic.json:basic.3",
"location": {
"kind": "file",
"file": "./basic2.json",
"file": "./basic.json",
"line": null,
"column": null
},
"name": "./basic2.json:basic2.3",
"name": "./basic.json:basic.3",
"messages": [],
"just_up": [],
"just_down": [],
Expand All @@ -61,14 +59,14 @@ lobster-json: wrote 6 items to basic2.lobster
"status": null
},
{
"tag": "json ./basic2.json:basic2.4",
"tag": "json ./basic.json:basic.4",
"location": {
"kind": "file",
"file": "./basic2.json",
"file": "./basic.json",
"line": null,
"column": null
},
"name": "./basic2.json:basic2.4",
"name": "./basic.json:basic.4",
"messages": [],
"just_up": [],
"just_down": [],
Expand All @@ -78,14 +76,14 @@ lobster-json: wrote 6 items to basic2.lobster
"status": null
},
{
"tag": "json ./basic2.json:basic2.5",
"tag": "json ./basic.json:basic.5",
"location": {
"kind": "file",
"file": "./basic2.json",
"file": "./basic.json",
"line": null,
"column": null
},
"name": "./basic2.json:basic2.5",
"name": "./basic.json:basic.5",
"messages": [],
"just_up": [],
"just_down": [],
Expand All @@ -98,14 +96,14 @@ lobster-json: wrote 6 items to basic2.lobster
"status": null
},
{
"tag": "json ./basic2.json:basic2.6",
"tag": "json ./basic.json:basic.6",
"location": {
"kind": "file",
"file": "./basic2.json",
"file": "./basic.json",
"line": null,
"column": null
},
"name": "./basic2.json:basic2.6",
"name": "./basic.json:basic.6",
"messages": [],
"just_up": [],
"just_down": [],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lobster-json: wrote 6 items to output.lobster
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--single
--tag-attribute=tags
--out=output.lobster
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// --tag-attribute=tags --name-attribute=name
[
{
"name" : "Test_1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"data": [
{
"tag": "json ./one/two/basic.json:one.two.basic.1",
"location": {
"kind": "file",
"file": "./one/two/basic.json",
"line": null,
"column": null
},
"name": "./one/two/basic.json:one.two.basic.1",
"messages": [],
"just_up": [],
"just_down": [],
"just_global": [],
"refs": [
"req example.req1"
],
"framework": "JSON",
"kind": "Test Vector",
"status": null
},
{
"tag": "json ./one/two/basic.json:one.two.basic.2",
"location": {
"kind": "file",
"file": "./one/two/basic.json",
"line": null,
"column": null
},
"name": "./one/two/basic.json:one.two.basic.2",
"messages": [],
"just_up": [],
"just_down": [],
"just_global": [],
"framework": "JSON",
"kind": "Test Vector",
"status": null
},
{
"tag": "json ./one/two/basic.json:one.two.basic.3",
"location": {
"kind": "file",
"file": "./one/two/basic.json",
"line": null,
"column": null
},
"name": "./one/two/basic.json:one.two.basic.3",
"messages": [],
"just_up": [],
"just_down": [],
"just_global": [],
"refs": [
"req example.req2",
"req example.req3"
],
"framework": "JSON",
"kind": "Test Vector",
"status": null
},
{
"tag": "json ./one/two/basic.json:one.two.basic.4",
"location": {
"kind": "file",
"file": "./one/two/basic.json",
"line": null,
"column": null
},
"name": "./one/two/basic.json:one.two.basic.4",
"messages": [],
"just_up": [],
"just_down": [],
"just_global": [],
"framework": "JSON",
"kind": "Test Vector",
"status": null
},
{
"tag": "json ./one/two/basic.json:one.two.basic.5",
"location": {
"kind": "file",
"file": "./one/two/basic.json",
"line": null,
"column": null
},
"name": "./one/two/basic.json:one.two.basic.5",
"messages": [],
"just_up": [],
"just_down": [],
"just_global": [],
"refs": [
"req example.req4"
],
"framework": "JSON",
"kind": "Test Vector",
"status": null
},
{
"tag": "json ./one/two/basic.json:one.two.basic.6",
"location": {
"kind": "file",
"file": "./one/two/basic.json",
"line": null,
"column": null
},
"name": "./one/two/basic.json:one.two.basic.6",
"messages": [],
"just_up": [],
"just_down": [],
"just_global": [],
"framework": "JSON",
"kind": "Test Vector",
"status": null
}
],
"generator": "lobster-json",
"schema": "lobster-act-trace",
"version": 3
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lobster-json: wrote 6 items to output.lobster
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--single
--tag-attribute=tags
--out=output.lobster
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"name" : "Test_1",
"tags" : ["example.req1"],
"inputs" : [1, 2],
"expect" : 3
},
{
"name" : "Test_2",
"tags" : [],
"inputs" : [1, 0],
"expect" : 1
},
{
"name" : "Test_3",
"tags" : ["example.req2",
"example.req3"],
"inputs" : [1, 0],
"expect" : 1
},
{
"name" : "Test_4",
"tags" : null,
"inputs" : [1, 0],
"expect" : 1
},
{
"name" : "Test_5",
"tags" : "example.req4",
"inputs" : [1, 0],
"expect" : 1
},
{
"name" : "Test_6",
"inputs" : [1, 0],
"expect" : 1
}
]
Loading
Loading