Skip to content

Commit

Permalink
Add some testing initial rollup testing. NFC (emscripten-core#23439)
Browse files Browse the repository at this point in the history
I think we we getting some indirect testing already via the vite tests I
added but this tests rollup directly, which will be useful once we start
developing the planning rollup plugin.
  • Loading branch information
sbc100 authored Jan 17, 2025
1 parent 0f6b437 commit c0fe9f2
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"eslint-config-prettier": "^9.1.0",
"globals": "^15.14.0",
"prettier": "^3.4.2",
"rollup": "^4.30.1",
"source-map": "0.7.4",
"typescript": "^5.7.2",
"vite": "^6.0.7",
Expand Down
6 changes: 6 additions & 0 deletions test/rollup/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<body>
<hr><div id='output'></div><hr>
<script type="module" src="./bundle.mjs"></script>
</body>
</html>
17 changes: 17 additions & 0 deletions test/rollup/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var params = {
print: (function() {
var element = document.getElementById('output');
return function(text) {
console.log(text);
element.innerHTML += text.replace('\n', '<br>', 'g') + '<br>';
};
})(),
canvas: document.getElementById('canvas'),
};

params.print("testing..");

import Module from './hello.mjs';
Module(params).then((instance) => {
console.log('loaded');
});
7 changes: 7 additions & 0 deletions test/rollup/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
input: 'index.mjs',
output: {
file: 'bundle.mjs',
format: 'es'
}
};
7 changes: 7 additions & 0 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5528,6 +5528,13 @@ def test_vite(self):
self.run_process(shared.get_npm_cmd('vite') + ['build'])
self.run_browser('vite/dist/index.html', '/report_result?exit:0')

def test_rollup(self):
shutil.copytree(test_file('rollup'), 'rollup')
with common.chdir('rollup'):
self.compile_btest('hello_world.c', ['-sEXPORT_ES6', '-sEXIT_RUNTIME', '-sMODULARIZE', '-o', 'hello.mjs'])
self.run_process(shared.get_npm_cmd('rollup') + ['--config'])
self.run_browser('rollup/index.html', '/report_result?exit:0')


class emrun(RunnerCore):
def test_emrun_info(self):
Expand Down

0 comments on commit c0fe9f2

Please sign in to comment.