tests/unit: Access shell sources from resource

Unit tests currently load shell sources directly from the
filesystem.

This is currently blocking generated sources - namely config.js - to
ESM, because a relative import from the source dir will fail to
locate the file in the build dir.

Address this by using the same GResource as gnome-shell instead of
direct filesystem access, as the resource will always include all
sources files at the expected location.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2880>
This commit is contained in:
Florian Müllner 2023-08-10 17:50:08 +02:00 committed by Marge Bot
parent 09525ece8c
commit 9546860d05
10 changed files with 20 additions and 20 deletions

View File

@ -263,7 +263,7 @@ if have_networkmanager
) )
endif endif
executable('gnome-shell-perf-helper', 'shell-perf-helper.c', executable('gnome-shell-perf-helper', 'shell-perf-helper.c', js_resources,
dependencies: [gtk_dep, gio_dep, m_dep], dependencies: [gtk_dep, gio_dep, m_dep],
include_directories: [conf_inc], include_directories: [conf_inc],
install_dir: libexecdir, install_dir: libexecdir,

View File

@ -5,8 +5,8 @@
const JsUnit = imports.jsUnit; const JsUnit = imports.jsUnit;
import Pango from 'gi://Pango'; import Pango from 'gi://Pango';
import '../../js/ui/environment.js'; import 'resource:///org/gnome/shell/ui/environment.js';
import * as Util from '../../js/misc/util.js'; import * as Util from 'resource:///org/gnome/shell/misc/util.js';
const tests = [ const tests = [
{ {

View File

@ -2,9 +2,9 @@ const JsUnit = imports.jsUnit;
import GObject from 'gi://GObject'; import GObject from 'gi://GObject';
import '../../js/ui/environment.js'; import 'resource:///org/gnome/shell/ui/environment.js';
import {InjectionManager} from '../../js/extensions/extension.js'; import {InjectionManager} from 'resource:///org/gnome/shell/extensions/extension.js';
class Object1 { class Object1 {
count = 0; count = 0;

View File

@ -4,11 +4,11 @@
// Needed so that Util can bring some UI stuff // Needed so that Util can bring some UI stuff
// we don't actually use // we don't actually use
import '../../js/ui/environment.js'; import 'resource:///org/gnome/shell/ui/environment.js';
import * as Assertions from '../common/assertions.js'; import * as Assertions from '../common/assertions.js';
import * as Util from '../../js/misc/util.js'; import * as Util from 'resource:///org/gnome/shell/misc/util.js';
let arrayInt = [1, 2, 3, 5, 6]; let arrayInt = [1, 2, 3, 5, 6];
Util.insertSorted(arrayInt, 4, (one, two) => one - two); Util.insertSorted(arrayInt, 4, (one, two) => one - two);

View File

@ -4,11 +4,11 @@
const JsUnit = imports.jsUnit; const JsUnit = imports.jsUnit;
import '../../js/ui/environment.js'; import 'resource:///org/gnome/shell/ui/environment.js';
import * as Assertions from '../common/assertions.js'; import * as Assertions from '../common/assertions.js';
import * as JsParse from '../../js/misc/jsParse.js'; import * as JsParse from 'resource:///org/gnome/shell/misc/jsParse.js';
const HARNESS_COMMAND_HEADER = 'let imports = obj;' + const HARNESS_COMMAND_HEADER = 'let imports = obj;' +
'let global = obj;' + 'let global = obj;' +

View File

@ -5,10 +5,10 @@
const JsUnit = imports.jsUnit; const JsUnit = imports.jsUnit;
import Pango from 'gi://Pango'; import Pango from 'gi://Pango';
import '../../js/ui/environment.js'; import 'resource:///org/gnome/shell/ui/environment.js';
import '../../js/ui/main.js'; import 'resource:///org/gnome/shell/ui/main.js';
import * as MessageList from '../../js/ui/messageList.js'; import * as MessageList from 'resource:///org/gnome/shell/ui/messageList.js';
/** /**
* Assert that `input`, assumed to be markup, gets "fixed" to `output`, * Assert that `input`, assumed to be markup, gets "fixed" to `output`,

View File

@ -1,5 +1,5 @@
const JsUnit = imports.jsUnit; const JsUnit = imports.jsUnit;
import * as Params from '../../js/misc/params.js'; import * as Params from 'resource:///org/gnome/shell/misc/params.js';
/** /**
* Asserts that two "param" objects have the same properties * Asserts that two "param" objects have the same properties

View File

@ -2,13 +2,13 @@
// Test cases for version comparison // Test cases for version comparison
import '../../js/ui/environment.js'; import 'resource:///org/gnome/shell/ui/environment.js';
import GObject from 'gi://GObject'; import GObject from 'gi://GObject';
const JsUnit = imports.jsUnit; const JsUnit = imports.jsUnit;
import * as Signals from '../../js/misc/signals.js'; import * as Signals from 'resource:///org/gnome/shell/misc/signals.js';
import {TransientSignalHolder, registerDestroyableType} from '../../js/misc/signalTracker.js'; import {TransientSignalHolder, registerDestroyableType} from 'resource:///org/gnome/shell/misc/signalTracker.js';
const Destroyable = GObject.registerClass({ const Destroyable = GObject.registerClass({
Signals: {'destroy': {}}, Signals: {'destroy': {}},

View File

@ -4,9 +4,9 @@
const JsUnit = imports.jsUnit; const JsUnit = imports.jsUnit;
import '../../js/ui/environment.js'; import 'resource:///org/gnome/shell/ui/environment.js';
import * as Util from '../../js/misc/util.js'; import * as Util from 'resource:///org/gnome/shell/misc/util.js';
const tests = [ const tests = [
{ {

View File

@ -4,9 +4,9 @@
const JsUnit = imports.jsUnit; const JsUnit = imports.jsUnit;
import '../../js/ui/environment.js'; import 'resource:///org/gnome/shell/ui/environment.js';
import * as Util from '../../js/misc/util.js'; import * as Util from 'resource:///org/gnome/shell/misc/util.js';
const tests = [ const tests = [
{ {