From 61e31ef9d0194a934d97390b46a34018e19578fd Mon Sep 17 00:00:00 2001 From: Justine West Date: Fri, 7 Jun 2024 15:49:43 -0700 Subject: [PATCH] add unit test for duplicate file names --- compiler/tools/fpp-to-dict/test/scripts/run.sh | 4 ++-- compiler/tools/fpp-to-dict/test/scripts/update-ref.sh | 2 +- compiler/tools/fpp-to-dict/test/top/dataProducts.ref.txt | 0 compiler/tools/fpp-to-dict/test/top/duplicate.fpp | 8 ++++++++ compiler/tools/fpp-to-dict/test/top/duplicate.ref.txt | 9 +++++++++ compiler/tools/fpp-to-dict/test/top/multipleTops.ref.txt | 0 compiler/tools/fpp-to-dict/test/top/run.sh | 6 ++++++ compiler/tools/fpp-to-dict/test/top/tests.sh | 1 + 8 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 compiler/tools/fpp-to-dict/test/top/dataProducts.ref.txt create mode 100644 compiler/tools/fpp-to-dict/test/top/duplicate.fpp create mode 100644 compiler/tools/fpp-to-dict/test/top/duplicate.ref.txt create mode 100644 compiler/tools/fpp-to-dict/test/top/multipleTops.ref.txt diff --git a/compiler/tools/fpp-to-dict/test/scripts/run.sh b/compiler/tools/fpp-to-dict/test/scripts/run.sh index 1bff92ee3..9c7468b6b 100644 --- a/compiler/tools/fpp-to-dict/test/scripts/run.sh +++ b/compiler/tools/fpp-to-dict/test/scripts/run.sh @@ -20,7 +20,7 @@ run_test() else outfile=$infile fi - $fpp_to_dict $args $infile.fpp 2>&1 + $fpp_to_dict $args $infile.fpp 2>&1 | remove_author | remove_path_prefix > $outfile.out.txt } . ./tests.sh @@ -31,7 +31,7 @@ do echo " $t() { - run_test $t + run_test '' $t }" done > default-tests.sh . ./default-tests.sh diff --git a/compiler/tools/fpp-to-dict/test/scripts/update-ref.sh b/compiler/tools/fpp-to-dict/test/scripts/update-ref.sh index 84cab5f60..a9169bb63 100644 --- a/compiler/tools/fpp-to-dict/test/scripts/update-ref.sh +++ b/compiler/tools/fpp-to-dict/test/scripts/update-ref.sh @@ -14,7 +14,7 @@ update() else outfile=$infile fi - $fpp_to_dict $args $infile.fpp 2>&1 + $fpp_to_dict $args $infile.fpp 2>&1 | remove_path_prefix > $outfile.ref.txt } for file in `find . -name '*.ref.txt'` diff --git a/compiler/tools/fpp-to-dict/test/top/dataProducts.ref.txt b/compiler/tools/fpp-to-dict/test/top/dataProducts.ref.txt new file mode 100644 index 000000000..e69de29bb diff --git a/compiler/tools/fpp-to-dict/test/top/duplicate.fpp b/compiler/tools/fpp-to-dict/test/top/duplicate.fpp new file mode 100644 index 000000000..927eb70c3 --- /dev/null +++ b/compiler/tools/fpp-to-dict/test/top/duplicate.fpp @@ -0,0 +1,8 @@ +module M { + + topology Duplicate { + } +} + +topology Duplicate { +} \ No newline at end of file diff --git a/compiler/tools/fpp-to-dict/test/top/duplicate.ref.txt b/compiler/tools/fpp-to-dict/test/top/duplicate.ref.txt new file mode 100644 index 000000000..6049448cd --- /dev/null +++ b/compiler/tools/fpp-to-dict/test/top/duplicate.ref.txt @@ -0,0 +1,9 @@ +fpp-to-dict +[ local path prefix ]/tools/fpp-to-dict/test/top/duplicate.fpp:7.1 +topology Duplicate { +^ +error: duplicate JSON file DuplicateTopologyDictionary.json +previous file would be generated here: +[ local path prefix ]/tools/fpp-to-dict/test/top/duplicate.fpp:3.3 + topology Duplicate { + ^ diff --git a/compiler/tools/fpp-to-dict/test/top/multipleTops.ref.txt b/compiler/tools/fpp-to-dict/test/top/multipleTops.ref.txt new file mode 100644 index 000000000..e69de29bb diff --git a/compiler/tools/fpp-to-dict/test/top/run.sh b/compiler/tools/fpp-to-dict/test/top/run.sh index d0c727e06..b6dd742cb 100644 --- a/compiler/tools/fpp-to-dict/test/top/run.sh +++ b/compiler/tools/fpp-to-dict/test/top/run.sh @@ -12,4 +12,10 @@ dataProducts() run_test "-i builtin.fpp -p 1.0.0 -f 3.4.3" dataProducts && \ validate_json_schema BasicDp && \ diff_json BasicDp +} + +duplicate() +{ + run_test '' duplicate && \ + compare duplicate } \ No newline at end of file diff --git a/compiler/tools/fpp-to-dict/test/top/tests.sh b/compiler/tools/fpp-to-dict/test/top/tests.sh index fddb418e0..14929e6ef 100644 --- a/compiler/tools/fpp-to-dict/test/top/tests.sh +++ b/compiler/tools/fpp-to-dict/test/top/tests.sh @@ -1,4 +1,5 @@ tests=" multipleTops dataProducts +duplicate "