From cf5adf0c646474f0259d123fad60ca5ed38ec891 Mon Sep 17 00:00:00 2001 From: Charles Brunet Date: Fri, 17 Mar 2023 16:27:37 -0400 Subject: add json output format to configure file --- .../269 configure file output format/compare.py | 5 +++ .../expected/config.h | 21 ++++++++++++ .../expected/config.json | 1 + .../expected/config.nasm | 17 ++++++++++ .../269 configure file output format/meson.build | 38 ++++++++++++++++++++++ 5 files changed, 82 insertions(+) create mode 100644 test cases/common/269 configure file output format/compare.py create mode 100644 test cases/common/269 configure file output format/expected/config.h create mode 100644 test cases/common/269 configure file output format/expected/config.json create mode 100644 test cases/common/269 configure file output format/expected/config.nasm create mode 100644 test cases/common/269 configure file output format/meson.build (limited to 'test cases') diff --git a/test cases/common/269 configure file output format/compare.py b/test cases/common/269 configure file output format/compare.py new file mode 100644 index 0000000..5188b02 --- /dev/null +++ b/test cases/common/269 configure file output format/compare.py @@ -0,0 +1,5 @@ +import sys + +with open(sys.argv[1], 'r', encoding='utf-8') as f, open(sys.argv[2], 'r', encoding='utf-8') as g: + if f.read() != g.read(): + sys.exit('contents are not equal') diff --git a/test cases/common/269 configure file output format/expected/config.h b/test cases/common/269 configure file output format/expected/config.h new file mode 100644 index 0000000..33cfd89 --- /dev/null +++ b/test cases/common/269 configure file output format/expected/config.h @@ -0,0 +1,21 @@ +/* + * Autogenerated by the Meson build system. + * Do not edit, your changes will be lost. + */ + +#pragma once + +#define bool + +#undef false + +/* ultimate question of life, the universe, and everything */ +#define int 42 + +/* This is +a multiline +description */ +#define str "hello world!" + +#define unquoted float + diff --git a/test cases/common/269 configure file output format/expected/config.json b/test cases/common/269 configure file output format/expected/config.json new file mode 100644 index 0000000..47d7832 --- /dev/null +++ b/test cases/common/269 configure file output format/expected/config.json @@ -0,0 +1 @@ +{"bool": true, "false": false, "int": 42, "str": "\"hello world!\"", "unquoted": "float"} \ No newline at end of file diff --git a/test cases/common/269 configure file output format/expected/config.nasm b/test cases/common/269 configure file output format/expected/config.nasm new file mode 100644 index 0000000..63c5c22 --- /dev/null +++ b/test cases/common/269 configure file output format/expected/config.nasm @@ -0,0 +1,17 @@ +; Autogenerated by the Meson build system. +; Do not edit, your changes will be lost. + +%define bool + +%undef false + +; ultimate question of life, the universe, and everything +%define int 42 + +; This is +; a multiline +; description +%define str "hello world!" + +%define unquoted float + diff --git a/test cases/common/269 configure file output format/meson.build b/test cases/common/269 configure file output format/meson.build new file mode 100644 index 0000000..796b9d6 --- /dev/null +++ b/test cases/common/269 configure file output format/meson.build @@ -0,0 +1,38 @@ +project('configure file output format') + +data = configuration_data() +data.set_quoted('str', 'hello world!', description: '''This is +a multiline +description''') +data.set('unquoted', 'float') +data.set('int', 42, description: 'ultimate question of life, the universe, and everything') +data.set('bool', true) +data.set('false', false) + +config_h = configure_file( + configuration: data, + output_format: 'c', + output: 'config.h' +) + +config_nasm = configure_file( + configuration: data, + output_format: 'nasm', + output: 'config.nasm' +) + +config_json = configure_file( + configuration: data, + output_format: 'json', + output: 'config.json' +) + +py = find_program('python3') +compare_py = files('compare.py') +expected_config_h = files('expected/config.h') +expected_config_nasm = files('expected/config.nasm') +expected_config_json = files('expected/config.json') + +test('c_output', py, args: [compare_py, expected_config_h, config_h]) +test('nasm_output', py, args: [compare_py, expected_config_nasm, config_nasm]) +test('json_output', py, args: [compare_py, expected_config_json, config_json]) -- cgit v1.1