]> begriffs open source - sa-parse/blob - tests/meson.build
ical parser
[sa-parse] / tests / meson.build
1 # Use Meson's filesystem module for portable file operations
2 fs = import('fs')
3
4 # Define test categories with their properties
5 csv_test_categories = {
6     'valid': {
7         'path': 'csv/valid',
8         'should_fail': false,
9     },
10     'invalid': {
11         'path': 'csv/invalid', 
12         'should_fail': true,
13     }
14 }
15
16 ical_test_categories = {
17     'valid': {
18         'path': 'ical/valid',
19         'should_fail': false,
20     },
21     'invalid': {
22         'path': 'ical/invalid', 
23         'should_fail': true,
24     }
25 }
26
27 # Auto-discover CSV files and create tests for each category
28 foreach category, props : csv_test_categories
29     # Find CSV files for this category
30     files_result = run_command('find', props['path'], '-name', '*.csv', '-type', 'f', check: true)
31     file_list = files_result.stdout().strip().split('\n')
32     csv_files = files(file_list)
33     
34     # Create tests for each file in this category
35     foreach test_file : csv_files
36         # Extract filename without extension
37         test_name = fs.stem(test_file)
38         
39         # Create the test with conditional should_fail
40         if props['should_fail']
41             test('csv_parser_' + category + '_' + test_name,
42                 csv_parser,
43                 args: [test_file],
44                 workdir: meson.current_source_dir(),
45                 timeout: 5,
46                 should_fail: true,
47                 env: {'CSV_TEST_MODE': category})
48         else
49             test('csv_parser_' + category + '_' + test_name,
50                 csv_parser,
51                 args: [test_file],
52                 workdir: meson.current_source_dir(),
53                 timeout: 5,
54                 env: {'CSV_TEST_MODE': category})
55         endif
56     endforeach
57 endforeach
58
59 # Auto-discover iCalendar files and create tests for each category
60 foreach category, props : ical_test_categories
61     # Find iCalendar files for this category
62     files_result = run_command('find', props['path'], '-name', '*.ics', '-type', 'f', check: true)
63     file_list = files_result.stdout().strip().split('\n')
64     ical_files = files(file_list)
65     
66     # Create tests for each file in this category
67     foreach test_file : ical_files
68         # Extract filename without extension
69         test_name = fs.stem(test_file)
70         
71         # Create the test with conditional should_fail
72         if props['should_fail']
73             test('ical_parser_' + category + '_' + test_name,
74                 ical_parser,
75                 args: [test_file],
76                 workdir: meson.current_source_dir(),
77                 timeout: 5,
78                 should_fail: true,
79                 env: {'ICAL_TEST_MODE': category})
80         else
81             test('ical_parser_' + category + '_' + test_name,
82                 ical_parser,
83                 args: [test_file],
84                 workdir: meson.current_source_dir(),
85                 timeout: 5,
86                 env: {'ICAL_TEST_MODE': category})
87         endif
88     endforeach
89 endforeach