summaryrefslogtreecommitdiffstats
path: root/test cases/unit/56 introspection
diff options
context:
space:
mode:
Diffstat (limited to 'test cases/unit/56 introspection')
-rw-r--r--test cases/unit/56 introspection/cp.py5
-rw-r--r--test cases/unit/56 introspection/meson.build72
-rw-r--r--test cases/unit/56 introspection/meson_options.txt2
-rw-r--r--test cases/unit/56 introspection/sharedlib/meson.build2
-rw-r--r--test cases/unit/56 introspection/sharedlib/shared.cpp9
-rw-r--r--test cases/unit/56 introspection/sharedlib/shared.hpp10
-rw-r--r--test cases/unit/56 introspection/staticlib/meson.build3
-rw-r--r--test cases/unit/56 introspection/staticlib/static.c5
-rw-r--r--test cases/unit/56 introspection/staticlib/static.h11
-rw-r--r--test cases/unit/56 introspection/t1.cpp13
-rw-r--r--test cases/unit/56 introspection/t2.cpp8
-rw-r--r--test cases/unit/56 introspection/t3.cpp16
12 files changed, 156 insertions, 0 deletions
diff --git a/test cases/unit/56 introspection/cp.py b/test cases/unit/56 introspection/cp.py
new file mode 100644
index 0000000..cb09cf3
--- /dev/null
+++ b/test cases/unit/56 introspection/cp.py
@@ -0,0 +1,5 @@
+#! /usr/bin/env python3
+
+import sys
+from shutil import copyfile
+copyfile(*sys.argv[1:])
diff --git a/test cases/unit/56 introspection/meson.build b/test cases/unit/56 introspection/meson.build
new file mode 100644
index 0000000..568d5cc
--- /dev/null
+++ b/test cases/unit/56 introspection/meson.build
@@ -0,0 +1,72 @@
+project('introspection', ['c', 'cpp'], version: '1.2.3', default_options: ['cpp_std=c++11', 'buildtype=debug'])
+
+dep1 = dependency('threads')
+dep2 = dependency('zlib', required: false)
+dep3 = dependency('bugDep1', required: get_option('test_opt1'))
+
+b1 = get_option('test_opt1')
+b2 = get_option('test_opt2')
+test_bool = b1 or b2
+test_bool = b1 and b2
+test_bool = not test_bool
+
+set_variable('list_test_plusassign', [])
+list_test_plusassign += ['bugs everywhere']
+dict_test = {list_test_plusassign[0]: 'even more bugs'}
+
+if not true
+ vers_str = '<=99.9.9'
+ dependency('somethingthatdoesnotexist', required: true, version: '>=1.2.3')
+ dependency('look_i_have_a_fallback', version: ['>=1.0.0', vers_str], fallback: ['oh_no', 'the_subproject_does_not_exist'])
+endif
+
+subdir('sharedlib')
+subdir('staticlib')
+
+var1 = '1'
+var2 = 2.to_string()
+var3 = 'test3'
+
+var4 = f'test @var1@ string' # TODO: Actually implement fstrings
+
+cus1 = custom_target('custom target test 1', output: 'file2', input: 'cp.py',
+ command: [find_program('cp.py'), '@INPUT@', '@OUTPUT@'])
+cus2 = custom_target('custom target test 2', output: 'file3', input: cus1,
+ command: [find_program('cp.py'), '@INPUT@', '@OUTPUT@'])
+
+t1 = executable('test' + var1, ['t1.cpp'], link_with: [sharedlib], install: not false, build_by_default: get_option('test_opt2'))
+t2 = executable('test@0@'.format('@0@'.format(var2)), sources: ['t2.cpp'], link_with: [staticlib])
+t3 = executable(var3, 't3.cpp', link_with: [sharedlib, staticlib], dependencies: [dep1])
+
+cus3 = custom_target('custom target test 3', output: 'file4', input: t3,
+ command: [find_program('cp.py'), '@INPUT@', '@OUTPUT@'])
+
+### BEGIN: Test inspired by taisei: https://github.com/taisei-project/taisei/blob/master/meson.build#L293
+systype = '@0@'.format(host_machine.system())
+systype = '@0@, @1@, @2@'.format(systype, host_machine.cpu_family(), host_machine.cpu())
+message(systype)
+### END: Test inspired by taisei
+
+# Minimal code version to produce bug #5376
+# Code inspired by https://github.com/mesa3d/mesa/blob/974c4d679c23373dbed386c696e3e3bc1bfa23ae/meson.build#L1341-L1347
+osmesa_lib_name = 'OSMesa'
+osmesa_bits = '8'
+osmesa_lib_name = osmesa_lib_name + osmesa_bits
+message(osmesa_lib_name) # Infinite recursion gets triggered here when the parameter osmesa_lib_name is resolved
+
+test('test case 1', t1)
+test('test case 2', t2, depends: t3)
+benchmark('benchmark 1', t3, args: [cus1, cus2, cus3])
+
+### Stuff to test the AST JSON printer
+foreach x : ['a', 'b', 'c']
+ if x == 'a'
+ message('a')
+ elif x == 'b'
+ message('a')
+ else
+ continue
+ endif
+ break
+ continue
+endforeach
diff --git a/test cases/unit/56 introspection/meson_options.txt b/test cases/unit/56 introspection/meson_options.txt
new file mode 100644
index 0000000..fc5cb4d
--- /dev/null
+++ b/test cases/unit/56 introspection/meson_options.txt
@@ -0,0 +1,2 @@
+option('test_opt1', type: 'boolean', value: false, description: 'simple boolean flag')
+option('test_opt2', type: 'boolean', value: true, description: 'simple boolean flag')
diff --git a/test cases/unit/56 introspection/sharedlib/meson.build b/test cases/unit/56 introspection/sharedlib/meson.build
new file mode 100644
index 0000000..7640bc7
--- /dev/null
+++ b/test cases/unit/56 introspection/sharedlib/meson.build
@@ -0,0 +1,2 @@
+SRC_shared = ['shared.cpp']
+sharedlib = shared_library('sharedTestLib', SRC_shared, extra_files: ['shared.hpp'])
diff --git a/test cases/unit/56 introspection/sharedlib/shared.cpp b/test cases/unit/56 introspection/sharedlib/shared.cpp
new file mode 100644
index 0000000..5030ab7
--- /dev/null
+++ b/test cases/unit/56 introspection/sharedlib/shared.cpp
@@ -0,0 +1,9 @@
+#include "shared.hpp"
+
+void SharedClass::doStuff() {
+ number++;
+}
+
+int SharedClass::getNumber() const {
+ return number;
+}
diff --git a/test cases/unit/56 introspection/sharedlib/shared.hpp b/test cases/unit/56 introspection/sharedlib/shared.hpp
new file mode 100644
index 0000000..dc9b2da
--- /dev/null
+++ b/test cases/unit/56 introspection/sharedlib/shared.hpp
@@ -0,0 +1,10 @@
+#pragma once
+
+class SharedClass {
+ private:
+ int number = 42;
+ public:
+ SharedClass() = default;
+ void doStuff();
+ int getNumber() const;
+}; \ No newline at end of file
diff --git a/test cases/unit/56 introspection/staticlib/meson.build b/test cases/unit/56 introspection/staticlib/meson.build
new file mode 100644
index 0000000..1cbb020
--- /dev/null
+++ b/test cases/unit/56 introspection/staticlib/meson.build
@@ -0,0 +1,3 @@
+SRC_static = ['static.c']
+extra_static = files(['static.h'])
+staticlib = static_library('staticTestLib', SRC_static, extra_files: extra_static)
diff --git a/test cases/unit/56 introspection/staticlib/static.c b/test cases/unit/56 introspection/staticlib/static.c
new file mode 100644
index 0000000..37ebc0d
--- /dev/null
+++ b/test cases/unit/56 introspection/staticlib/static.c
@@ -0,0 +1,5 @@
+#include "static.h"
+
+int add_numbers(int a, int b) {
+ return a + b;
+} \ No newline at end of file
diff --git a/test cases/unit/56 introspection/staticlib/static.h b/test cases/unit/56 introspection/staticlib/static.h
new file mode 100644
index 0000000..06da508
--- /dev/null
+++ b/test cases/unit/56 introspection/staticlib/static.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int add_numbers(int a, int b);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/test cases/unit/56 introspection/t1.cpp b/test cases/unit/56 introspection/t1.cpp
new file mode 100644
index 0000000..901e3f1
--- /dev/null
+++ b/test cases/unit/56 introspection/t1.cpp
@@ -0,0 +1,13 @@
+#include "sharedlib/shared.hpp"
+
+int main(void) {
+ SharedClass cl1;
+ if(cl1.getNumber() != 42) {
+ return 1;
+ }
+ cl1.doStuff();
+ if(cl1.getNumber() != 43) {
+ return 2;
+ }
+ return 0;
+}
diff --git a/test cases/unit/56 introspection/t2.cpp b/test cases/unit/56 introspection/t2.cpp
new file mode 100644
index 0000000..8323f46
--- /dev/null
+++ b/test cases/unit/56 introspection/t2.cpp
@@ -0,0 +1,8 @@
+#include "staticlib/static.h"
+
+int main(void) {
+ if(add_numbers(1, 2) != 3) {
+ return 1;
+ }
+ return 0;
+}
diff --git a/test cases/unit/56 introspection/t3.cpp b/test cases/unit/56 introspection/t3.cpp
new file mode 100644
index 0000000..dd518e8
--- /dev/null
+++ b/test cases/unit/56 introspection/t3.cpp
@@ -0,0 +1,16 @@
+#include "sharedlib/shared.hpp"
+#include "staticlib/static.h"
+
+int main(void) {
+ for(int i = 0; i < 1000; add_numbers(i, 1)) {
+ SharedClass cl1;
+ if(cl1.getNumber() != 42) {
+ return 1;
+ }
+ cl1.doStuff();
+ if(cl1.getNumber() != 43) {
+ return 2;
+ }
+ }
+ return 0;
+}