diff --git a/README.md b/README.md index 5c5d82746..0b1039a0c 100644 --- a/README.md +++ b/README.md @@ -99,11 +99,11 @@ General documentation surrounding workers development and using `wrangler` can b wrangler subdomain ``` - After you have registered a subdomain, add `workers_dot_dev` to your `wrangler.toml`. + After you have registered a subdomain, add `workers_dev` to your `wrangler.toml`. | Key | Value | Example | | --------------- | ----- | ------------------------ | -| workers_dot_dev | true | `workers_dot_dev = true` | +| workers_dev | true | `workers_dev = true` | #### Publishing to your own domain @@ -111,7 +111,7 @@ If you would like to publish to your own domain, you will need to specify these | Key | Value | Example | | --------------- | ---------------------------------------------------------------------- | ---------------------------------------------- | -| workers_dot_dev | false | `workers_dot_dev = false` | +| workers_dev | false | `workers_dev = false` | | route | The route you would like to publish to | `route = "example.com/my-worker/*"` | | zone_id | Your Cloudflare zone ID, this can be found in the Cloudflare dashboard | `zone_id = "b6558acaf2b4cad1f2b51c5236a6b972"` | @@ -198,17 +198,17 @@ There are two types of configuration that `wrangler` uses: global user and per p - `webpack`: This project contains any number of JavaScript files or Rust/C/C++ files that compile to WebAssembly. Rust files will be built with `wasm-pack`. This project type uses webpack and webpack plugins in the background to build your worker. - - `zone_id`: This is the ID of the "zone" or domain you want to run your script on. This is optional if you are using a [workers.dev](https://workers.dev) subdomain and is only required when `workers_dot_dev` is false, or excluded from an [environment](https://github.com/cloudflare/wrangler/blob/master/docs/environments.md) configuration. + - `zone_id`: This is the ID of the "zone" or domain you want to run your script on. This is optional if you are using a [workers.dev](https://workers.dev) subdomain and is only required when `workers_dev` is false, or excluded from an [environment](https://github.com/cloudflare/wrangler/blob/master/docs/environments.md) configuration. - `account_id`: This is the ID of the account associated with your zone. You might have more than one account, so make sure to use the ID of the account associated with the `zone_id` you provide, if you provide one. - `route`: This is the route you'd like to use your worker on. You need to include the hostname. Examples: - `*example.com/*` - `http://example.com/hello` - This key is optional if you are using a [workers.dev](https://workers.dev) subdomain and is only required when `workers_dot_dev` is false, or excluded from an [environment](https://github.com/cloudflare/wrangler/blob/master/docs/environments.md). + This key is optional if you are using a [workers.dev](https://workers.dev) subdomain and is only required when `workers_dev` is false, or excluded from an [environment](https://github.com/cloudflare/wrangler/blob/master/docs/environments.md). - `webpack_config`: This is the path to the webpack configuration file for your worker. This is optional and defaults to `webpack.config.js` - - `workers_dot_dev`: This is a boolean flag that specifies if your worker will be deployed to your [workers.dev](https://workers.dev) subdomain. For more information, please read the [environments documentation](https://github.com/cloudflare/wrangler/blob/master/docs/environments.md). + - `workers_dev`: This is a boolean flag that specifies if your worker will be deployed to your [workers.dev](https://workers.dev) subdomain. For more information, please read the [environments documentation](https://github.com/cloudflare/wrangler/blob/master/docs/environments.md). - `kv-namespaces`: These specify any [Workers KV](https://workers.cloudflare.com/docs/reference/storage/) Namespaces you want to access from inside your Worker. Each namespace you include should have an entry in your `wrangler.toml` that includes: diff --git a/docs/content/environments.md b/docs/content/environments.md index 8f59e2b5b..180982f16 100644 --- a/docs/content/environments.md +++ b/docs/content/environments.md @@ -16,7 +16,7 @@ name = "my-worker-dev" account_id = "12345678901234567890" zone_id = "09876543210987654321" route = "dev.example.com/*" -workers_dot_dev = false +workers_dev = false # environment configuration [env.staging] @@ -34,7 +34,7 @@ route = "example.com/*" The most common use case for environments is deploying to a staging subdomain before your production environment. `wrangler publish` will look at your top level configuration, and you can specify other environments beneath it. Each of these environments will inherit the values from the top level configuration if they are not specified, with the following caveats. * `type` will always be inherited from the top-level configuration; you cannot specify different types for different environments. -* Fields that can be inherited from the top level are `account_id`, `zone_id`, `workers_dot_dev`, and `webpack_config`. `kv_namespaces` and `route` must be defined for each environment and will not be inherited. +* Fields that can be inherited from the top level are `account_id`, `zone_id`, `workers_dev`, and `webpack_config`. `kv_namespaces` and `route` must be defined for each environment and will not be inherited. * `name` is inherited. If left out of the environment configuration, a Worker project named `my-worker` with an environment `[env.dev]` would become `my-worker-dev`. ### Examples @@ -51,7 +51,7 @@ name = "my-worker" account_id = "12345678901234567890" zone_id = "09876543210987654321" route = "example.com/*" -workers_dot_dev = false # this field specifies that the worker should not be deployed to workers.dev +workers_dev = false # this field specifies that the worker should not be deployed to workers.dev ``` ```console @@ -69,7 +69,7 @@ This `wrangler.toml` has no environments defined and will publish `my-worker` to type = "webpack" name = "my-worker" account_id = "12345678901234567890" -workers_dot_dev = true # this field specifies that the worker should be deployed to workers.dev +workers_dev = true # this field specifies that the worker should be deployed to workers.dev ``` ```console @@ -89,7 +89,7 @@ name = "my-worker-dev" account_id = "12345678901234567890" zone_id = "09876543210987654321" route = "dev.example.com/*" -workers_dot_dev = false +workers_dev = false [env.staging] name = "my-worker-staging" @@ -127,7 +127,7 @@ $ wrangler publish --env production #### Staging Environment with workers.dev -In order to deploy your code to workers.dev, you must include `workers_dot_dev = true` in the desired environment. Your `wrangler.toml` may look like this: +In order to deploy your code to workers.dev, you must include `workers_dev = true` in the desired environment. Your `wrangler.toml` may look like this: ```toml name = "my-worker" @@ -135,10 +135,10 @@ type = "webpack" account_id = "12345678901234567890" zone_id = "09876543210987654321" route = "example.com/*" -workers_dot_dev = false +workers_dev = false [env.staging] -workers_dot_dev = true +workers_dev = true ``` With this configuration, Wrangler will behave in the following manner: @@ -165,7 +165,7 @@ If you only want to deploy to workers.dev you can configure Wrangler like so: name = "my-worker-dev" type = "webpack" account_id = "12345678901234567890" -workers_dot_dev = true +workers_dev = true [env.production] name = "my-worker" @@ -205,7 +205,7 @@ You can specify different webpack configurations for different environments. name = "my-worker-dev" type = "webpack" account_id = "12345678901234567890" -workers_dot_dev = true +workers_dev = true webpack_config = "webpack.dev.js" [env.production] @@ -226,7 +226,7 @@ You can specify different kv namespaces for different environments. name = "my-worker" type = "webpack" account_id = "12345678901234567890" -workers_dot_dev = true +workers_dev = true kv-namespaces = [ { binding = "KV", id = "06779da6940b431db6e566b4846d64db" } ] @@ -249,7 +249,7 @@ type = "webpack" account_id = "12345678901234567890" zone_id = "09876543210987654321" route = "example.com/*" -workers_dot_dev = true +workers_dev = true [env.staging] type = "rust" @@ -267,11 +267,11 @@ type = "webpack" account_id = "12345678901234567890" zone_id = "09876543210987654321" route = "example.com/*" -workers_dot_dev = false +workers_dev = false [env.staging] name = "my-worker" -workers_dot_dev = true +workers_dev = true ``` ```console @@ -294,18 +294,18 @@ zone_id = "09876543210987654321" route = "example.com/* ``` -You will be warned if `workers_dot_dev` is left out of the top level configuration because if it is not specified, it is unclear what the behavior of `wrangler publish` should be. See [the section on backwards compatibility](#Backwards-compatibility) for more information. +You will be warned if `workers_dev` is left out of the top level configuration because if it is not specified, it is unclear what the behavior of `wrangler publish` should be. See [the section on backwards compatibility](#Backwards-compatibility) for more information. ```console $ wrangler publish -⚠️ Please specify the workers_dot_dev boolean in the top level of your wrangler.toml. -⚠️ This command will fail in v1.5.0. Please see https://github.com/cloudflare/wrangler/blob/master/docs/content/environments.md for more information. +⚠️ Please specify the workers_dev boolean in the top level of your wrangler.toml. +⚠️ If you do not add workers_dev, this command may act unexpectedly in v1.5.0. Please see https://github.com/cloudflare/wrangler/blob/master/docs/content/environments.md for more information. ✨ Built successfully, built project size is 517 bytes. ✨ Successfully published your script. -✨ Success! Your worker was successfully published. You can view it at https://my-worker.avery.workers.dev +✨ Success! Your worker was successfully published. You can view it at https://my-worker..workers.dev ``` -### Defining workers_dot_dev and route +### Defining workers_dev and route ```toml name = "my-worker" @@ -313,23 +313,23 @@ type = "webpack" account_id = "12345678901234567890" zone_id = "09876543210987654321" route = "example.com/*" -workers_dot_dev = true +workers_dev = true [env.staging] -workers_dot_dev = true +workers_dev = true route = "staging.example.com/*" ``` -Wrangler will fail to publish to an environment where `route` is defined alongside `workers_dot_dev = true`. +Wrangler will fail to publish to an environment where `route` is defined alongside `workers_dev = true`. ```console $ wrangler publish -Error: ⚠️ Your environment should only include `workers_dot_dev` or `route`. If you are trying to publish to workers.dev, remove `route` from your wrangler.toml, if you are trying to publish to your own domain, remove `workers_dot_dev`. +Error: ⚠️ Your environment should only include `workers_dev` or `route`. If you are trying to publish to workers.dev, remove `route` from your wrangler.toml, if you are trying to publish to your own domain, remove `workers_dev`. ``` ```console $ wrangler publish --env staging -Error: ⚠️ Your environment should only include `workers_dot_dev` or `route`. If you are trying to publish to workers.dev, remove `route` from your wrangler.toml, if you are trying to publish to your own domain, remove `workers_dot_dev`. +Error: ⚠️ Your environment should only include `workers_dev` or `route`. If you are trying to publish to workers.dev, remove `route` from your wrangler.toml, if you are trying to publish to your own domain, remove `workers_dev`. ``` ## Backwards compatibility @@ -353,9 +353,9 @@ With this configuration, Wrangler will behave in the following manner: ```console $ wrangler publish -⚠️ The `private` field is deprecated; please use `workers_dot_dev` to toggle between publishing to your workers.dev subdomain and your own domain. -⚠️ Please specify the workers_dot_dev boolean in the top level of your wrangler.toml. -⚠️ This command will fail in v1.5.0. Please see https://github.com/cloudflare/wrangler/blob/master/docs/content/environments.md for more information. +⚠️ The `private` field is deprecated; please use `workers_dev` to toggle between publishing to your workers.dev subdomain and your own domain. +⚠️ Please specify the workers_dev boolean in the top level of your wrangler.toml. +⚠️ If you do not add workers_dev, this command may act unexpectedly in v1.5.0. Please see https://github.com/cloudflare/wrangler/blob/master/docs/content/environments.md for more information. ✨ Built successfully, built project size is 517 bytes. ✨ Successfully published your script. ✨ Success! Your worker was successfully published. You can view it at https://my-worker..workers.dev @@ -364,14 +364,14 @@ $ wrangler publish ```console $ wrangler publish --release ⚠️ --release will be deprecated. -⚠️ The `private` field is deprecated; please use `workers_dot_dev` to toggle between publishing to your workers.dev subdomain and your own domain. -⚠️ Please specify the workers_dot_dev boolean in the top level of your wrangler.toml. -⚠️ This command will fail in v1.5.0. Please see https://github.com/cloudflare/wrangler/blob/master/docs/content/environments.md for more information. +⚠️ The `private` field is deprecated; please use `workers_dev` to toggle between publishing to your workers.dev subdomain and your own domain. +⚠️ Please specify the workers_dev boolean in the top level of your wrangler.toml. +⚠️ If you do not add workers_dev, this command may act unexpectedly in v1.5.0. Please see https://github.com/cloudflare/wrangler/blob/master/docs/content/environments.md for more information. ✨ Built successfully, built project size is 517 bytes. ✨ Successfully published your script. ✨ Success! Your worker was successfully published. You can view it at example.com/* ``` -This backwards compatibility is the reason that a warning is thrown if `workers_dot_dev` is not specified at the top of `wrangler.toml`. +This backwards compatibility is the reason that a warning is thrown if `workers_dev` is not specified at the top of `wrangler.toml`. -It is important to note that both of these commands will issue a deprecation warning. To remove these warnings, you can configure Wrangler with the `workers_dot_dev` boolean to separate deploys to workers.dev from deploys to workers routes. +It is important to note that both of these commands will issue a deprecation warning. To remove these warnings, you can configure Wrangler with the `workers_dev` boolean to separate deploys to workers.dev from deploys to workers routes. diff --git a/docs/content/kv_commands.md b/docs/content/kv_commands.md index af692dc46..32d0071e8 100644 --- a/docs/content/kv_commands.md +++ b/docs/content/kv_commands.md @@ -92,7 +92,7 @@ type = "webpack" name = "my-worker" account_id = "" route = "staging.example.com/*" -workers_dot_dev = false +workers_dev = false kv-namespaces = [ { binding = "KV", id = "06779da6940b431db6e566b4846d64db" } diff --git a/src/commands/build/wranglerjs/bundle.rs b/src/commands/build/wranglerjs/bundle.rs index a2a1a6c90..be6e2802b 100644 --- a/src/commands/build/wranglerjs/bundle.rs +++ b/src/commands/build/wranglerjs/bundle.rs @@ -7,8 +7,6 @@ use std::io::prelude::*; use std::path::{Path, PathBuf}; use crate::commands::build::wranglerjs::output::WranglerjsOutput; -#[cfg(test)] -use crate::terminal::message; // Directory where we should write the {Bundle}. It represents the built // artifact. @@ -142,7 +140,6 @@ mod tests { fn cleanup(name: String) { let current_dir = env::current_dir().unwrap(); let path = Path::new(¤t_dir).join(name); - message::info(&format!("p: {:?}", path)); fs::remove_dir_all(path).unwrap(); } } diff --git a/src/commands/build/wranglerjs/mod.rs b/src/commands/build/wranglerjs/mod.rs index a26207548..676990204 100644 --- a/src/commands/build/wranglerjs/mod.rs +++ b/src/commands/build/wranglerjs/mod.rs @@ -206,8 +206,7 @@ fn run_npm_install(dir: PathBuf) -> Result<(), failure::Error> { info!("skipping npm install because node_modules exists"); } - // TODO(sven): figure out why the file doesn't exits in some cases? Even if - // the thread should have locked it. + // TODO(sven): figure out why the file doesn't exits in some cases? if flock_path.exists() { fs::remove_file(&flock_path)?; } diff --git a/src/commands/kv/mod.rs b/src/commands/kv/mod.rs index ada44e6ad..9495041f6 100644 --- a/src/commands/kv/mod.rs +++ b/src/commands/kv/mod.rs @@ -154,7 +154,7 @@ mod tests { route: None, routes: None, webpack_config: None, - workers_dot_dev: false, + workers_dev: false, zone_id: None, }; assert!(kv::get_namespace_id(&target_with_dup_kv_bindings, "").is_err()); diff --git a/src/commands/publish/mod.rs b/src/commands/publish/mod.rs index ef31f3bb8..a39505e0c 100644 --- a/src/commands/publish/mod.rs +++ b/src/commands/publish/mod.rs @@ -18,7 +18,7 @@ use crate::settings::target::Target; use crate::terminal::{emoji, message}; pub fn publish(user: &GlobalUser, target: &Target) -> Result<(), failure::Error> { - info!("workers_dot_dev = {}", target.workers_dot_dev); + info!("workers_dev = {}", target.workers_dev); validate_target(target)?; commands::build(&target)?; @@ -51,7 +51,7 @@ fn publish_script(user: &GlobalUser, target: &Target) -> Result<(), failure::Err ) } - let pattern = if !target.workers_dot_dev { + let pattern = if !target.workers_dev { let route = Route::new(&target)?; Route::publish(&user, &target, &route)?; info!("publishing to route"); @@ -127,7 +127,7 @@ fn validate_target(target: &Target) -> Result<(), failure::Error> { None => {} } - let destination = if !target.workers_dot_dev { + let destination = if !target.workers_dev { // check required fields for release if target .zone_id diff --git a/src/settings/target/mod.rs b/src/settings/target/mod.rs index 8fbe0a823..18e6bfd9c 100644 --- a/src/settings/target/mod.rs +++ b/src/settings/target/mod.rs @@ -27,7 +27,7 @@ pub struct Target { pub route: Option, pub routes: Option>, pub webpack_config: Option, - pub workers_dot_dev: bool, + pub workers_dev: bool, pub zone_id: Option, } @@ -47,7 +47,7 @@ pub struct Environment { pub route: Option, pub routes: Option>, pub webpack_config: Option, - pub workers_dot_dev: Option, + pub workers_dev: Option, pub zone_id: Option, } @@ -64,7 +64,7 @@ pub struct Manifest { pub route: Option, pub routes: Option>, pub webpack_config: Option, - pub workers_dot_dev: Option, + pub workers_dev: Option, pub zone_id: Option, } @@ -119,11 +119,11 @@ impl Manifest { release: bool, ) -> Result<(Option, bool), failure::Error> { let use_dot_dev_failure = - "Please specify the workers_dot_dev boolean in the top level of your wrangler.toml."; + "Please specify the workers_dev boolean in the top level of your wrangler.toml."; let use_dot_dev_warning = - format!("{}\n{} This command will fail in v1.5.0. Please see https://github.com/cloudflare/wrangler/blob/master/docs/environments.md for more information.", use_dot_dev_failure, emoji::WARN); + format!("{}\n{} If you do not add workers_dev, this command may act unexpectedly in v1.5.0. Please see https://github.com/cloudflare/wrangler/blob/master/docs/content/environments.md for more information.", use_dot_dev_failure, emoji::WARN); let wdd_failure = format!( - "{} Your environment should only include \"workers_dot_dev\" or \"route\". If you are trying to publish to workers.dev, remove `route` from your wrangler.toml, if you are trying to publish to your own domain, remove `workers_dot_dev`.", + "{} Your environment should only include `workers_dev` or `route`. If you are trying to publish to workers.dev, remove `route` from your wrangler.toml, if you are trying to publish to your own domain, remove `workers_dev`.", emoji::WARN ); @@ -131,20 +131,20 @@ impl Manifest { // switch wrangler publish behavior to act the same at top level // and environments // brace yourself, this is hairy - let workers_dot_dev = match environment { + let workers_dev = match environment { // top level configuration None => { if release { - match self.workers_dot_dev { + match self.workers_dev { Some(_) => { failure::bail!(format!("{} {}", emoji::WARN, use_dot_dev_failure)) } None => { message::warn(&use_dot_dev_warning); - false // wrangler publish --release w/o workers_dot_dev is zoned deploy + false // wrangler publish --release w/o workers_dev is zoned deploy } } - } else if let Some(wdd) = self.workers_dot_dev { + } else if let Some(wdd) = self.workers_dev { if wdd { if let Some(route) = &self.route { if !route.is_empty() { @@ -155,20 +155,20 @@ impl Manifest { wdd } else { message::warn(&use_dot_dev_warning); - true // wrangler publish w/o workers_dot_dev is zoneless deploy + true // wrangler publish w/o workers_dev is zoneless deploy } } // environment configuration Some(environment) => { - if let Some(wdd) = environment.workers_dot_dev { + if let Some(wdd) = environment.workers_dev { if wdd && environment.route.is_some() { failure::bail!(wdd_failure) } wdd - } else if let Some(wdd) = self.workers_dot_dev { + } else if let Some(wdd) = self.workers_dev { if wdd && environment.route.is_some() { - false // allow route to override workers_dot_dev = true if wdd is inherited + false // allow route to override workers_dev = true if wdd is inherited } else { wdd // inherit from top level } @@ -180,7 +180,7 @@ impl Manifest { let route = if let Some(environment) = environment { if let Some(route) = &environment.route { - if let Some(wdd) = environment.workers_dot_dev { + if let Some(wdd) = environment.workers_dev { if wdd { failure::bail!(wdd_failure); } @@ -193,12 +193,12 @@ impl Manifest { self.route.clone() }; - Ok((route, workers_dot_dev)) + Ok((route, workers_dev)) } fn check_private(&self, environment: Option<&Environment>) { let deprecate_private_warning = "The `private` field is deprecated; please use \ - `workers_dot_dev` to toggle between publishing to your workers.dev subdomain and your own domain."; + `workers_dev` to toggle between publishing to your workers.dev subdomain and your own domain."; // Check for the presence of the 'private' field in top-level config; if present, warn. if self.private.is_some() { @@ -218,9 +218,9 @@ impl Manifest { environment_name: Option<&str>, release: bool, ) -> Result { - if release && self.workers_dot_dev.is_some() { + if release && self.workers_dev.is_some() { failure::bail!(format!( - "{} The --release flag is not compatible with use of the workers_dot_dev field.", + "{} The --release flag is not compatible with use of the workers_dev field.", emoji::WARN )) } @@ -234,7 +234,7 @@ impl Manifest { account_id: self.account_id.clone(), // MAY inherit webpack_config: self.webpack_config.clone(), // MAY inherit zone_id: self.zone_id.clone(), // MAY inherit - workers_dot_dev: true, // MAY inherit, + workers_dev: true, // MAY inherit, // importantly, the top level name will be modified // to include the name of the environment name: self.name.clone(), // MAY inherit @@ -247,9 +247,9 @@ impl Manifest { self.check_private(environment); - let (route, workers_dot_dev) = self.negotiate_zoneless(environment, release)?; + let (route, workers_dev) = self.negotiate_zoneless(environment, release)?; target.route = route; - target.workers_dot_dev = workers_dot_dev; + target.workers_dev = workers_dev; if let Some(environment) = environment { target.name = if let Some(name) = &environment.name { name.clone() @@ -293,7 +293,7 @@ impl Manifest { route: Some(String::new()), routes: None, webpack_config: None, - workers_dot_dev: Some(true), + workers_dev: Some(true), zone_id: Some(String::new()), }; diff --git a/tests/build.rs b/tests/build.rs index 867c42344..749227528 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -1,3 +1,6 @@ +#[macro_use] +extern crate lazy_static; + use assert_cmd::prelude::*; use fs_extra::dir::{copy, CopyOptions}; use std::env; @@ -7,6 +10,11 @@ use std::io::prelude::*; use std::path::{Path, PathBuf}; use std::process::Command; use std::str; +use std::sync::Mutex; + +lazy_static! { + static ref BUILD_LOCK: Mutex = Mutex::new(0); +} const BUNDLE_OUT: &str = "./worker"; @@ -19,6 +27,7 @@ macro_rules! single_env_settings { name = "test" zone_id = "" account_id = "" + workers_dev = true {} "#, $x @@ -171,8 +180,8 @@ fn it_builds_with_webpack_wast() { } #[test] -fn it_fails_with_webpack_target_web() { - let fixture = "webpack_target_web"; +fn it_fails_with_webpack_target_node() { + let fixture = "webpack_target_node"; create_temporary_copy(fixture); webpack_config( @@ -193,6 +202,29 @@ fn it_fails_with_webpack_target_web() { cleanup(fixture); } +#[test] +fn it_fails_with_webpack_target_web() { + let fixture = "webpack_target_web"; + create_temporary_copy(fixture); + + webpack_config( + fixture, + r#"{ + entry: "./index.js", + target: "web", + }"#, + ); + single_env_settings! {fixture, r#" + type = "webpack" + "#}; + + build_fails_with( + fixture, + "Building a Cloudflare Worker with target \"web\" is not supported", + ); + cleanup(fixture); +} + #[test] fn it_builds_with_webpack_target_webworker() { let fixture = "webpack_target_webworker"; @@ -229,12 +261,18 @@ fn cleanup(fixture: &str) { } fn build(fixture: &str) { + // Lock to avoid having concurrent builds + let _g = BUILD_LOCK.lock().unwrap(); + let mut build = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); build.current_dir(fixture_path(fixture)); build.arg("build").assert().success(); } fn build_fails_with(fixture: &str, expected_message: &str) { + // Lock to avoid having concurrent builds + let _g = BUILD_LOCK.lock().unwrap(); + let mut build = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); build.current_dir(fixture_path(fixture)); build.arg("build"); diff --git a/tests/fixtures/webpack_target_node/index.js b/tests/fixtures/webpack_target_node/index.js new file mode 100644 index 000000000..e69de29bb diff --git a/tests/preview.rs b/tests/preview.rs index 15067e911..775a3fee7 100644 --- a/tests/preview.rs +++ b/tests/preview.rs @@ -1,3 +1,6 @@ +#[macro_use] +extern crate lazy_static; + use assert_cmd::prelude::*; use fs_extra::dir::{copy, CopyOptions}; use std::env; @@ -7,6 +10,11 @@ use std::io::prelude::*; use std::path::{Path, PathBuf}; use std::process::Command; use std::str; +use std::sync::Mutex; + +lazy_static! { + static ref BUILD_LOCK: Mutex = Mutex::new(0); +} macro_rules! settings { ( $f:expr, $x:expr ) => { @@ -17,6 +25,7 @@ macro_rules! settings { name = "test" zone_id = "" account_id = "" + workers_dev = true {} "#, $x @@ -59,6 +68,9 @@ fn it_can_preview_rust_project() { } fn preview(fixture: &str) { + // Lock to avoid having concurrent builds + let _g = BUILD_LOCK.lock().unwrap(); + let mut preview = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); preview.current_dir(fixture_path(fixture)); preview.arg("preview").assert().success();