Skip to content

Commit

Permalink
Set lib_path to import.meta.url by default to make it easier to hotli…
Browse files Browse the repository at this point in the history
…nk the dist/ files.

Update regtest-html to run all Adrift 4 tests and to test the Inform 7 template from a file: URL.
  • Loading branch information
curiousdannii committed Apr 23, 2023
1 parent 5c384f2 commit cfaa1fb
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"eslint-plugin-compat": "^4.0.0",
"http-server": "^14.0.0",
"minimist": "^1.2.6",
"regtest-html": "^0.1.1",
"regtest-html": "^0.1.2",
"typescript": "^4.7.4"
},
"scripts": {
Expand Down
10 changes: 9 additions & 1 deletion src/common/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ export async function fetch_vm_resource(options: ParchmentOptions, path: string)
}

// Something else, like a .wasm
const response = await fetch(options.lib_path + path)
// Handle when lib_path is a proper URL (such as import.meta.url), as well as the old style path fragment
let url
try {
url = new URL(path, options.lib_path)
}
catch (_) {
url = options.lib_path + path
}
const response = await fetch(url)
if (!response.ok) {
throw new Error(`Could not fetch ${path}, got ${response.status}`)
}
Expand Down
23 changes: 23 additions & 0 deletions src/common/formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,29 @@ export const formats = [
],
},

/*{
id: 'adrift5',
extensions: /\.(blb|blorb)/i,
engines: [
{
id: 'frankendrift',
load: ['./frankendrift.js'],
start: (options, requires) => {
const [file_data, FrankenDrift] = requires
const vm = new FrankenDrift.FrankenDrift()
const vm_options = Object.assign({}, options, {
vm,
Glk,
})
vm.init(file_data, vm_options)
Glk.init(vm_options)
},
},
],
},*/

{
id: 'hugo',
extensions: /\.hex/i,
Expand Down
3 changes: 2 additions & 1 deletion src/common/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export function get_default_options(): ParchmentOptions {
],
do_vm_autosave: 1,
GlkOte: new WebGlkOte(),
lib_path: 'dist/web/',
// This only makes sense after the source files are built
lib_path: import.meta.url,
proxy_url: 'https://iplayif.com/proxy/',
set_body_to_page_bg: 1,
theme_cookie: 'parchment_theme',
Expand Down
4 changes: 2 additions & 2 deletions tests/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ run_test() {

echo 'Adrift 4'
# RegTest-HTML will need some updates to do the whole Hamper test
$REGTEST -t ${2:-10} -i index.html src/upstream/emglken/tests/Hamper.taf.regtest prologue || ((FAILURES++))
run_test Hamper.taf.regtest
echo 'Glulx'
run_test glulxercise.ulx.regtest
echo 'Hugo'
Expand All @@ -39,6 +39,6 @@ python ./tests/ifsitegen.py \
-r tests/Release \
src/upstream/emglken/tests/advent.z5

$REGTEST -t 10 --pdf -i tests/Release/index.html src/upstream/emglken/tests/advent.z5.regtest || ((FAILURES++))
$REGTEST -t 10 --pdf -i "file://$(pwd)/tests/Release/index.html" src/upstream/emglken/tests/advent.z5.regtest || ((FAILURES++))

exit $FAILURES

0 comments on commit cfaa1fb

Please sign in to comment.