summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Mubashshir <ahm@jadupc.com>2023-10-08 18:48:06 +0600
committerLibravatar Mubashshir <ahm@jadupc.com>2023-10-08 18:50:58 +0600
commit0a994adf3c6feab7d50b4bea01659436e4c695b4 (patch)
tree63812ecb2049a2e003b5340d47522dbc914d2c9b
parentd5c12ef35ae5b26df0ae6507002ad18b2f7c22b4 (diff)
downloadjadupc-remote-support-console-0a994adf3c6feab7d50b4bea01659436e4c695b4.tar.gz
jadupc-remote-support-console-0a994adf3c6feab7d50b4bea01659436e4c695b4.zip
test: Add unit test for parser
Signed-off-by: Mubashshir <ahm@jadupc.com>
-rw-r--r--meson.build4
-rw-r--r--src/meson.build2
-rw-r--r--src/tmate/meson.build2
-rw-r--r--tests/Tmate.StdoutParser.vala26
-rw-r--r--tests/meson.build10
5 files changed, 43 insertions, 1 deletions
diff --git a/meson.build b/meson.build
index 09fc662..78dac0a 100644
--- a/meson.build
+++ b/meson.build
@@ -31,6 +31,8 @@ valac = meson.get_compiler ('vala')
conf = configuration_data ()
srcs = []
+tests = []
+
i18n_data = []
vapi_overrides = []
@@ -59,6 +61,8 @@ foreach override : vapi_overrides
add_project_arguments('--vapidir=@0@'.format(meson.current_source_dir() / 'vapi' / override), language: 'vala')
endforeach
+subdir('tests')
+
executable(application_name, srcs + resources,
include_directories: config_h_dir,
vala_args: '--target-glib=2.50', dependencies: deps,
diff --git a/src/meson.build b/src/meson.build
index 9cac7f5..5ab8e8e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -20,3 +20,5 @@ deps = [
config_h,
config_dep
]
+
+srcs += tests
diff --git a/src/tmate/meson.build b/src/tmate/meson.build
index 7b907aa..e1ea5da 100644
--- a/src/tmate/meson.build
+++ b/src/tmate/meson.build
@@ -1,4 +1,4 @@
-srcs += files(
+tests += files(
'config.vala',
'sessiontype.vala',
'session.vala',
diff --git a/tests/Tmate.StdoutParser.vala b/tests/Tmate.StdoutParser.vala
new file mode 100644
index 0000000..c619274
--- /dev/null
+++ b/tests/Tmate.StdoutParser.vala
@@ -0,0 +1,26 @@
+static int main()
+{
+ string test = """
+To connect to the session locally, run: tmate -S /tmp/tmate-1000/YSOfCR attach
+ssh.tmate.io lookup failure. Retrying in 2 seconds (non-recoverable failure in name resolution)
+Connecting to ssh.tmate.io...
+web session read only: https://tmate.io/t/ro-S9JDuEGmhJNJNELQMqpUvSYG7
+ssh session read only: ssh ro-S9JDuEGmhJNJNELQMqpUvSYG7@sgp1.tmate.io
+web session: https://tmate.io/t/NK5pSsnftmJuzsGxzjNdLJUCP
+ssh session: ssh NK5pSsnftmJuzsGxzjNdLJUCP@sgp1.tmate.io
+A mate has joined (160.202.145.245) -- 1 client currently connected
+Session shell restarted
+A mate has left (160.202.145.245) -- 0 client currently connected
+Error reading from channel: Socket error: Connection timed out
+Error connecting: Failed to connect: Network is unreachable
+Reconnecting...
+Session closed
+""";
+
+ foreach(var line in test.split("\n")) {
+ var token = (new Tmate.Stdout()).parse(line);
+ assert(token.class != Tmate.Stdout.TokenType.UNKNOWN);
+ print(@"$token\n");
+ }
+ return 0;
+}
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..60ca59e
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,10 @@
+foreach target : [
+ 'Tmate.StdoutParser'
+]
+ test('Test-@0@'.format(target),
+ executable('Test-@0@'.format(target),
+ files('@0@.vala'.format(target)) + tests,
+ dependencies: deps,
+ c_args: ['-include', 'config.h'],
+ ))
+endforeach