forked from icd/rentgen
Compare commits
No commits in common. "8bf58a2cb1af59cca8b3a768d9d2adbf2fabb67f" and "8f47b56a20493f4d39d2023501d2cf664abca325" have entirely different histories.
8bf58a2cb1
...
8f47b56a20
15
Dockerfile
15
Dockerfile
@ -47,8 +47,10 @@ FROM node:lts AS runtime
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy built extension from builder
|
# Copy built artifacts from builder
|
||||||
COPY --from=builder /app /app
|
COPY --from=builder /app/web-ext-artifacts /app/web-ext-artifacts
|
||||||
|
COPY --from=builder /app/package.json /app/package-lock.json ./
|
||||||
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
|
|
||||||
# Install Firefox and Xvfb for headless execution (cached layer)
|
# Install Firefox and Xvfb for headless execution (cached layer)
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
@ -82,10 +84,9 @@ CMD ["echo", "Use verify stage for testing"]
|
|||||||
# Integration test stage - automated testing with exit code
|
# Integration test stage - automated testing with exit code
|
||||||
FROM runtime AS integration_test
|
FROM runtime AS integration_test
|
||||||
|
|
||||||
# Copy verification scripts
|
# Copy verification script
|
||||||
COPY tests/test_verify.py /app/tests/test_verify.py
|
COPY tests/test_verify.py /app/test_verify.py
|
||||||
COPY tests/test-lib.js /app/tests/test-lib.js
|
RUN chmod +x /app/test_verify.py
|
||||||
RUN chmod +x /app/tests/test_verify.py
|
|
||||||
|
|
||||||
# Run verification and exit with proper exit code
|
# Run verification and exit with proper exit code
|
||||||
CMD ["python3", "/app/tests/test_verify.py"]
|
CMD ["python3", "/app/test_verify.py"]
|
||||||
|
|||||||
20
Makefile
Normal file
20
Makefile
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
.PHONY: verify clean help
|
||||||
|
|
||||||
|
# Default target - run verification
|
||||||
|
verify:
|
||||||
|
@echo "Building and verifying Rentgen extension..."
|
||||||
|
docker compose up --force-recreate --build --abort-on-container-exit --exit-code-from rentgen_verify
|
||||||
|
@echo "✓ Verification completed successfully!"
|
||||||
|
|
||||||
|
# Clean up Docker resources
|
||||||
|
clean:
|
||||||
|
docker compose down --rmi local --volumes --remove-orphans
|
||||||
|
|
||||||
|
# Help target
|
||||||
|
help:
|
||||||
|
@echo "Rentgen Extension - Makefile"
|
||||||
|
@echo ""
|
||||||
|
@echo "Available targets:"
|
||||||
|
@echo " make verify - Build and verify extension (exits with error if verification fails)"
|
||||||
|
@echo " make clean - Clean up Docker resources"
|
||||||
|
@echo " make help - Show this help message"
|
||||||
@ -1,11 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
rentgen_build:
|
|
||||||
build: .
|
|
||||||
|
|
||||||
rentgen_check:
|
rentgen_check:
|
||||||
build:
|
build: .
|
||||||
context: .
|
|
||||||
target: code_quality
|
|
||||||
|
|
||||||
rentgen_run:
|
rentgen_run:
|
||||||
build:
|
build:
|
||||||
@ -17,5 +12,5 @@ services:
|
|||||||
rentgen_verify:
|
rentgen_verify:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
target: integration_test
|
target: verify
|
||||||
restart: "no"
|
restart: "no"
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"matches": ["<all_urls>"],
|
"matches": ["<all_urls>"],
|
||||||
"js": ["lib/tests/test-content-script.js"],
|
"js": ["lib/test-content-script.js"],
|
||||||
"run_at": "document_end"
|
"run_at": "document_end"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
1257
package-lock.json
generated
1257
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -19,9 +19,7 @@
|
|||||||
"create-package:firefox": "web-ext build --overwrite-dest --artifacts-dir ../web-ext-artifacts",
|
"create-package:firefox": "web-ext build --overwrite-dest --artifacts-dir ../web-ext-artifacts",
|
||||||
"create-package:chrome": "cd dist-chrome && 7z a -tzip ../web-ext-artifacts/rentgen-chrome-0.1.10.zip * && cd ..",
|
"create-package:chrome": "cd dist-chrome && 7z a -tzip ../web-ext-artifacts/rentgen-chrome-0.1.10.zip * && cd ..",
|
||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit",
|
||||||
"lint": "web-ext lint",
|
"lint": "web-ext lint"
|
||||||
"docker:verify": "docker compose up --force-recreate --build --abort-on-container-exit --exit-code-from rentgen_verify",
|
|
||||||
"docker:clean": "docker compose down --rmi local --volumes --remove-orphans"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@ -1,36 +0,0 @@
|
|||||||
// Test library for Marionette-based extension verification
|
|
||||||
// This JavaScript code runs in the browser context via Marionette
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test that background script performs computation correctly
|
|
||||||
* @param {number} testValue - Input value for computation
|
|
||||||
* @returns {Promise<number|null>} - Computed result or null on failure
|
|
||||||
*/
|
|
||||||
function testBackgroundComputation(testValue) {
|
|
||||||
// Check if content script loaded
|
|
||||||
if (!document.body.getAttribute('data-rentgen-injected')) {
|
|
||||||
return -1; // Content script not loaded
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dispatch test request to content script
|
|
||||||
document.dispatchEvent(new CustomEvent('rentgen_test_request', {
|
|
||||||
detail: { value: testValue, timestamp: Date.now() }
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Wait for background response
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
let attempts = 0;
|
|
||||||
const checkInterval = setInterval(() => {
|
|
||||||
attempts++;
|
|
||||||
const computed = document.body.getAttribute('data-rentgen-computed');
|
|
||||||
|
|
||||||
if (computed) {
|
|
||||||
clearInterval(checkInterval);
|
|
||||||
resolve(parseInt(computed));
|
|
||||||
} else if (attempts > 50) {
|
|
||||||
clearInterval(checkInterval);
|
|
||||||
resolve(null);
|
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@ -70,17 +70,36 @@ def test_addition():
|
|||||||
test_value = 17
|
test_value = 17
|
||||||
expected = 37
|
expected = 37
|
||||||
|
|
||||||
# Load test library
|
result = client.execute_script("""
|
||||||
test_lib_path = os.path.join(os.path.dirname(__file__), 'test-lib.js')
|
const testValue = arguments[0];
|
||||||
with open(test_lib_path, 'r') as f:
|
|
||||||
test_lib = f.read()
|
|
||||||
|
|
||||||
# Execute test
|
// Check if content script loaded
|
||||||
result = client.execute_script(
|
if (!document.body.getAttribute('data-rentgen-injected')) {
|
||||||
test_lib + "\nreturn testBackgroundComputation(arguments[0]);",
|
return -1; // Content script not loaded
|
||||||
script_args=[test_value],
|
}
|
||||||
script_timeout=10000
|
|
||||||
)
|
// Dispatch test request to content script
|
||||||
|
document.dispatchEvent(new CustomEvent('rentgen_test_request', {
|
||||||
|
detail: { value: testValue, timestamp: Date.now() }
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Wait for background response
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
let attempts = 0;
|
||||||
|
const checkInterval = setInterval(() => {
|
||||||
|
attempts++;
|
||||||
|
const computed = document.body.getAttribute('data-rentgen-computed');
|
||||||
|
|
||||||
|
if (computed) {
|
||||||
|
clearInterval(checkInterval);
|
||||||
|
resolve(parseInt(computed));
|
||||||
|
} else if (attempts > 50) {
|
||||||
|
clearInterval(checkInterval);
|
||||||
|
resolve(null);
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
""", script_args=[test_value], script_timeout=10000)
|
||||||
|
|
||||||
client.close()
|
client.close()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user