Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
matrix:
node-version: [12.x, 14.x]
steps:
- name: Install dependencies
run: sudo apt install flatpak
- uses: actions/checkout@v2
- name: Tests with Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
"compile": "tsc -p ./",
"lint": "eslint src --ext ts",
"watch": "tsc -watch -p ./",
"pretest": "yarn run compile && copyfiles -u 1 src/test/assets/* out/ && yarn run lint --max-warnings=0",
"pretest": "yarn run compile && cp -r src/test/assets out/test/assets && yarn run lint --max-warnings=0",
"test": "node ./out/test/runTest.js",
"deploy-vs": "vsce publish --yarn",
"deploy-ovsx": "ovsx publish --yarn"
Expand Down
19 changes: 19 additions & 0 deletions src/test/assets/meson/build-aux/meson/postinstall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python3

from os import environ, path
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the new meson post install, the less files we have for tests the better.

from subprocess import call

prefix = environ.get("MESON_INSTALL_PREFIX", "/usr/local")
datadir = path.join(prefix, "share")
destdir = environ.get("DESTDIR", "")

# Package managers set this so we don't need to run
if not destdir:
print("Updating icon cache...")
call(["gtk-update-icon-cache", "-qtf", path.join(datadir, "icons", "hicolor")])

print("Updating desktop database...")
call(["update-desktop-database", "-q", path.join(datadir, "applications")])

print("Compiling GSettings schemas...")
call(["glib-compile-schemas", path.join(datadir, "glib-2.0", "schemas")])
41 changes: 41 additions & 0 deletions src/test/assets/meson/data/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
desktop_file = i18n.merge_file(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need such sophisticated thing, we can just install_data and copy the file to the right directory, handling translations and validations are imho a bit out of scope of such a test case.

input: 'some.meson.Project.desktop.in',
output: 'some.meson.Project.desktop',
type: 'desktop',
po_dir: '../po',
install: true,
install_dir: join_paths(get_option('datadir'), 'applications')
)

desktop_utils = find_program('desktop-file-validate', required: false)
if desktop_utils.found()
test('Validate desktop file', desktop_utils,
args: [desktop_file]
)
endif

appstream_file = i18n.merge_file(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly here, do we even need an appdata file?

input: 'some.meson.Project.appdata.xml.in',
output: 'some.meson.Project.appdata.xml',
po_dir: '../po',
install: true,
install_dir: join_paths(get_option('datadir'), 'appdata')
)

appstream_util = find_program('appstream-util', required: false)
if appstream_util.found()
test('Validate appstream file', appstream_util,
args: ['validate', appstream_file]
)
endif

install_data('some.meson.Project.gschema.xml',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gschema should definitely be removed

install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas')
)

compile_schemas = find_program('glib-compile-schemas', required: false)
if compile_schemas.found()
test('Validate schema file', compile_schemas,
args: ['--strict', '--dry-run', meson.current_source_dir()]
)
endif
9 changes: 9 additions & 0 deletions src/test/assets/meson/data/some.meson.Project.appdata.xml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>some.meson.Project.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>LicenseRef-proprietary</project_license>
<description>
<p>No description</p>
</description>
</component>
8 changes: 8 additions & 0 deletions src/test/assets/meson/data/some.meson.Project.desktop.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Desktop Entry]
Name=meson
Exec=meson
Icon=some.meson.Project
Terminal=false
Type=Application
Categories=GTK;
StartupNotify=true
4 changes: 4 additions & 0 deletions src/test/assets/meson/data/some.meson.Project.gschema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="meson">
<schema id="some.meson.Project" path="/some/meson/Project/"/>
</schemalist>
15 changes: 15 additions & 0 deletions src/test/assets/meson/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
project('meson',
version: '0.1.0',
meson_version: '>= 0.50.0',
default_options: [ 'warning_level=2',
],
)

i18n = import('i18n')



subdir('data')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would avoid using subdirs, just put all the necessary files for the test on the same directory.

subdir('src')

meson.add_install_script('build-aux/meson/postinstall.py')
38 changes: 38 additions & 0 deletions src/test/assets/meson/some.meson.Project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"app-id": "some.meson.Project",
"runtime": "org.gnome.Platform",
"runtime-version": "41",
"sdk": "org.gnome.Sdk",
"command": "meson",
"finish-args": [
"--share=network",
"--share=ipc",
"--socket=fallback-x11",
"--device=dri",
"--socket=wayland"
],
"cleanup": [
"/include",
"/lib/pkgconfig",
"/man",
"/share/doc",
"/share/gtk-doc",
"/share/man",
"/share/pkgconfig",
"*.la",
"*.a"
],
"modules": [
{
"name": "meson",
"builddir": true,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we actually handle the builddir argument in flatpak-vscode it is mostly used by builder to whether build stuff in current directory or do so in the cache directory.

"buildsystem": "meson",
"sources": [
{
"type": "dir",
"url": "."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"url": "."
"path": "."

}
]
}
]
}
Empty file.
2 changes: 2 additions & 0 deletions src/test/assets/meson/src/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def main(version: str):
print(f"Hi from a meson project {version}")
24 changes: 24 additions & 0 deletions src/test/assets/meson/src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
moduledir = join_paths(pkgdatadir, 'meson')

python = import('python')

conf = configuration_data()
conf.set('PYTHON', python.find_installation('python3').path())
conf.set('VERSION', meson.project_version())
conf.set('pkgdatadir', pkgdatadir)

configure_file(
input: 'meson.in',
output: 'meson',
configuration: conf,
install: true,
install_dir: get_option('bindir')
)

meson_sources = [
'__init__.py',
'main.py',
]

install_data(meson_sources, install_dir: moduledir)
13 changes: 13 additions & 0 deletions src/test/assets/meson/src/meson.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!@PYTHON@


import sys

pkgdatadir = '@pkgdatadir@'
version = '@VERSION@'

sys.path.insert(1, pkgdatadir)

if __name__ == '__main__':
from meson import main
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just do the print call here and drop the other file?

sys.exit(main.main(version))
20 changes: 20 additions & 0 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,26 @@ suite('manifest', () => {
const postInstallCommand2 = manifest?.build(true).slice(-1)[0]
assert(postInstallCommand2?.toString().endsWith('echo \'hello\''))
})

test('meson build', async function () {
const manifest = await parseManifest(intoUri('../assets/meson/some.meson.Project.json'))

if (manifest === null) {
throw new Error('Failed to parse manifest of meson project.')
}

console.log(manifest.initBuild().execSync())
console.log(manifest.updateDependencies().execSync())
console.log(manifest.buildDependencies().execSync())

for (const command of manifest.build(false)) {
console.log(command.execSync())
}

console.log(manifest.run().execSync())

assert.equal(manifest.run().execSync().toString(), 'Hi from a meson project 0.1.1')
})
})

suite('utils', () => {
Expand Down