Skip to content

Commit f25f0b9

Browse files
authored
Merge pull request #72 from mkantor/make-debug-snapshots-work-for-release
Make snapshots portable across debug/release builds.
2 parents 7c34d62 + c43bc2f commit f25f0b9

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

tests/integration_tests.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ async fn samples_match_snapshots() {
3434
// If dynamic content files mention where the repo is checked
3535
// out, redact it to keep tests portable.
3636
.map(|(key, value)| (key, value.replace(PROJECT_DIRECTORY, "$PROJECT_DIRECTORY")))
37+
// Also redact release modes in paths so we can release with
38+
// snapshots generated during debug builds.
39+
.map(|(key, value)| (key, value.replace("target/debug", "target/$PROFILE")))
40+
.map(|(key, value)| (key, value.replace("target/release", "target/$PROFILE")))
3741
// Also remove the prefix used on log messages.
3842
.map(|(key, value)| (key, String::from(log_prefix_regex.replace_all(&value, ""))))
3943
.collect::<BTreeMap<_, _>>();

tests/snapshots/integration_tests__executables.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ cat.txt.sh: ""
88
count-cli-args.txt.sh: "0\n"
99
error.txt.sh: "Unable to emit rendered content.\n\nCaused by:\n Process exited with code 1: boom!\n \n"
1010
get-pwd.txt.hbs: "this is pwd from subdirectory:\n$PROJECT_DIRECTORY/samples/executables/subdirectory\n"
11-
get-render-data.json.hbs: "{\"/\":{\"NO-SNAPSHOT-random\":\"/NO-SNAPSHOT-random\",\"NO-SNAPSHOT-system-info\":\"/NO-SNAPSHOT-system-info\",\"cat\":\"/cat\",\"count-cli-args\":\"/count-cli-args\",\"error\":\"/error\",\"get-pwd\":\"/get-pwd\",\"get-render-data\":\"/get-render-data\",\"ls\":\"/ls\",\"output-and-error\":\"/output-and-error\",\"pwd\":\"/pwd\",\"render-data\":\"/render-data\",\"slow\":\"/slow\",\"slow-error\":\"/slow-error\",\"slow-template\":\"/slow-template\",\"subdirectory/\":{\"pwd\":\"/subdirectory/pwd\"}},\"server-info\":{\"version\":\"0.3.0\",\"operator-path\":\"$PROJECT_DIRECTORY/target/debug/operator\",\"socket-address\":\"$SOCKET_ADDRESS\"},\"target-media-type\":\"application/json\",\"request\":{\"route\":\"/get-render-data\",\"query-parameters\":{}},\"error-code\":null}\n"
11+
get-render-data.json.hbs: "{\"/\":{\"NO-SNAPSHOT-random\":\"/NO-SNAPSHOT-random\",\"NO-SNAPSHOT-system-info\":\"/NO-SNAPSHOT-system-info\",\"cat\":\"/cat\",\"count-cli-args\":\"/count-cli-args\",\"error\":\"/error\",\"get-pwd\":\"/get-pwd\",\"get-render-data\":\"/get-render-data\",\"ls\":\"/ls\",\"output-and-error\":\"/output-and-error\",\"pwd\":\"/pwd\",\"render-data\":\"/render-data\",\"slow\":\"/slow\",\"slow-error\":\"/slow-error\",\"slow-template\":\"/slow-template\",\"subdirectory/\":{\"pwd\":\"/subdirectory/pwd\"}},\"server-info\":{\"version\":\"0.3.0\",\"operator-path\":\"$PROJECT_DIRECTORY/target/$PROFILE/operator\",\"socket-address\":\"$SOCKET_ADDRESS\"},\"target-media-type\":\"application/json\",\"request\":{\"route\":\"/get-render-data\",\"query-parameters\":{}},\"error-code\":null}\n"
1212
ls.txt.sh: "NO-SNAPSHOT-random.bin.sh\nNO-SNAPSHOT-system-info.html.sh\ncat.txt.sh\ncount-cli-args.txt.sh\nerror.txt.sh\nget-pwd.txt.hbs\nget-render-data.json.hbs\nls.txt.sh\noutput-and-error.txt.sh\npwd.txt.sh\nrender-data.json.sh\nslow-error.txt.sh\nslow-template.txt.hbs\nslow.txt.sh\nsubdirectory\n"
1313
output-and-error.txt.sh: "Unable to emit rendered content.\n\nCaused by:\n Process exited with code 1\n"
1414
pwd.txt.sh: "$PROJECT_DIRECTORY/samples/executables\n"
15-
render-data.json.sh: "{\"/\":{\"NO-SNAPSHOT-random\":\"/NO-SNAPSHOT-random\",\"NO-SNAPSHOT-system-info\":\"/NO-SNAPSHOT-system-info\",\"cat\":\"/cat\",\"count-cli-args\":\"/count-cli-args\",\"error\":\"/error\",\"get-pwd\":\"/get-pwd\",\"get-render-data\":\"/get-render-data\",\"ls\":\"/ls\",\"output-and-error\":\"/output-and-error\",\"pwd\":\"/pwd\",\"render-data\":\"/render-data\",\"slow\":\"/slow\",\"slow-error\":\"/slow-error\",\"slow-template\":\"/slow-template\",\"subdirectory/\":{\"pwd\":\"/subdirectory/pwd\"}},\"server-info\":{\"version\":\"0.3.0\",\"operator-path\":\"$PROJECT_DIRECTORY/target/debug/operator\",\"socket-address\":\"$SOCKET_ADDRESS\"},\"target-media-type\":\"application/json\",\"request\":{\"route\":\"/render-data\",\"query-parameters\":{}},\"error-code\":null}\n"
15+
render-data.json.sh: "{\"/\":{\"NO-SNAPSHOT-random\":\"/NO-SNAPSHOT-random\",\"NO-SNAPSHOT-system-info\":\"/NO-SNAPSHOT-system-info\",\"cat\":\"/cat\",\"count-cli-args\":\"/count-cli-args\",\"error\":\"/error\",\"get-pwd\":\"/get-pwd\",\"get-render-data\":\"/get-render-data\",\"ls\":\"/ls\",\"output-and-error\":\"/output-and-error\",\"pwd\":\"/pwd\",\"render-data\":\"/render-data\",\"slow\":\"/slow\",\"slow-error\":\"/slow-error\",\"slow-template\":\"/slow-template\",\"subdirectory/\":{\"pwd\":\"/subdirectory/pwd\"}},\"server-info\":{\"version\":\"0.3.0\",\"operator-path\":\"$PROJECT_DIRECTORY/target/$PROFILE/operator\",\"socket-address\":\"$SOCKET_ADDRESS\"},\"target-media-type\":\"application/json\",\"request\":{\"route\":\"/render-data\",\"query-parameters\":{}},\"error-code\":null}\n"
1616
slow-error.txt.sh: "Unable to emit rendered content.\n\nCaused by:\n Process exited with code 1: Boom!\n \n"
1717
slow-template.txt.hbs: "🔴 Ready…\n🟡 Set…\n🟢 Go!\n🏁 Finished!\n"
1818
slow.txt.sh: "🔴 Ready…\n🟡 Set…\n🟢 Go!\n"

tests/snapshots/integration_tests__render-context.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ a.html: "a\n"
88
request-route-wrapper.txt.hbs: "route from this file: /request-route-wrapper\nroute from file included via partial: /request-route-wrapper\nroute from file included via get helper: /request-route-wrapper"
99
request-route.txt.hbs: /request-route
1010
routes.txt.hbs: "a: /a\nrequest-route: /request-route\nrequest-route-wrapper: /request-route-wrapper\nroutes: /routes\nserver-info: /server-info\nwith-empty-context: /with-empty-context\n"
11-
server-info.txt.hbs: "version: 0.3.0\noperator-path: $PROJECT_DIRECTORY/target/debug/operator\nsocket-address: $SOCKET_ADDRESS\n"
11+
server-info.txt.hbs: "version: 0.3.0\noperator-path: $PROJECT_DIRECTORY/target/$PROFILE/operator\nsocket-address: $SOCKET_ADDRESS\n"
1212
with-empty-context.html.hbs: "this with normal context: [object]\nthis with funky context: true\ncalling get for static content with funky context: a\n\n"
1313

0 commit comments

Comments
 (0)