-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensures that opossum can run in a browser. Also - removed Makefile in favor of an npm-only build process. Fixes: #6
- Loading branch information
Showing
8 changed files
with
131 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
node_modules | ||
docs | ||
coverage | ||
dist | ||
test/browser/browserified-tests.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// for browser output | ||
// TODO: This is all pretty hackey | ||
const log = console.log; | ||
const inBrowser = typeof document !== 'undefined'; | ||
|
||
function enable () { | ||
console.log = function () { | ||
if (inBrowser) { | ||
printToBrowser(arguments[0]); | ||
} | ||
log.apply(log, Array.prototype.slice.call(arguments)); | ||
}; | ||
} | ||
|
||
function disable () { | ||
console.log = log; | ||
} | ||
|
||
function printToBrowser (line) { | ||
if (!line || line.length < 1) return; | ||
const p = document.body.appendChild(document.createElement('p')); | ||
const statusBar = document.getElementById('status-bar'); | ||
if (line.startsWith('ok') || line.startsWith('# pass')) { | ||
p.style.color = 'green'; | ||
} else if (line.startsWith('not ok') || line.startsWith('# fail')) { | ||
p.style.color = 'red'; | ||
statusBar.style.backgroundColor = 'red'; | ||
} else if (line.startsWith('# tests')) { | ||
p.className = 'test-count'; | ||
} else if (line.startsWith('#')) { | ||
p.className = 'test-case'; | ||
} | ||
p.innerHTML = line; | ||
} | ||
|
||
module.exports = exports = { | ||
enable, disable | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!doctype html> | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
|
||
<title>Testing Opossum</title> | ||
<meta name="description" content="Testing Opossum"> | ||
<meta name="author" content="lball@redhat.com"> | ||
<style> | ||
body { | ||
margin: 1em; | ||
font-family: sans-serif; | ||
font-size: large; | ||
} | ||
p { | ||
margin: 1ex; | ||
} | ||
p.test-case, p.test-count { | ||
font-weight: bold; | ||
padding-top: 1.5em; | ||
border-top: 1px dotted; | ||
} | ||
div#status-bar { | ||
width: 100%; | ||
height: 2em; | ||
background-color: green; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<!-- load opossum --> | ||
<script src="../../browser/opossum-min.js"></script> | ||
<!-- load the test --> | ||
<script src="browserified-tests.js"></script> | ||
<div id='status-bar'></div> | ||
<div id='results'> | ||
<h1>Opossum Test Results</h1> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters