diff options
author | Charles Brunet <charles.brunet@optelgroup.com> | 2023-03-17 16:27:37 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2023-08-31 07:52:41 -0400 |
commit | cf5adf0c646474f0259d123fad60ca5ed38ec891 (patch) | |
tree | 85ccd32aa73eecf274a937f1fc3b6f4d484b77da /test cases | |
parent | cd30d1889f2bae34f17231b9cabe665edd57e7ba (diff) | |
download | meson-cf5adf0c646474f0259d123fad60ca5ed38ec891.zip meson-cf5adf0c646474f0259d123fad60ca5ed38ec891.tar.gz meson-cf5adf0c646474f0259d123fad60ca5ed38ec891.tar.bz2 |
add json output format to configure file
Diffstat (limited to 'test cases')
5 files changed, 82 insertions, 0 deletions
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]) |