@@ -72,12 +72,6 @@ namespace
7272 protected:
7373 std::string rcbinpath;
7474 std::string tempdir;
75-
76- const std::string manifest_json = R"( {
77- "bundle.symbolic_name" : "main",
78- "bundle.version" : "0.1.0",
79- "bundle.activator" : true
80- })" ;
8175 };
8276
8377 // A zip file containing only a manifest.
@@ -370,15 +364,26 @@ TEST_F(ResourceCompilerTest, testEscapePath)
370364
371365TEST_F (ResourceCompilerTest, testManifestAdd)
372366{
367+ const std::string manifest_json = R"( {
368+ "bundle.symbolic_name" : "mybundle",
369+ "bundle.version" : "0.1.0",
370+ "bundle.activator" : true
371+ })" ;
373372 createDirHierarchy (tempdir, manifest_json);
374373
375- std::ostringstream cmd;
376- cmd << rcbinpath;
377- cmd << " --bundle-name "
378- << " mybundle" ;
379- cmd << " --out-file \" " << tempdir << " Example.zip\" " ;
380- cmd << " --manifest-add \" " << tempdir << " manifest.json\" " ;
374+ std::ostringstream badcmd;
375+ badcmd << rcbinpath
376+ << " --bundle-name mismatched_bundle_name"
377+ << " --out-file \" " << tempdir << " Example.zip\" "
378+ << " --manifest-add \" " << tempdir << " manifest.json\" " ;
379+ // Test that invoking command with --bundle-name different from that in the manifest fails.
380+ ASSERT_NE (EXIT_SUCCESS, runExecutable (badcmd.str ()));
381381
382+ std::ostringstream cmd;
383+ cmd << rcbinpath
384+ << " --bundle-name mybundle"
385+ << " --out-file \" " << tempdir << " Example.zip\" "
386+ << " --manifest-add \" " << tempdir << " manifest.json\" " ;
382387 // Test that Cmdline invocation in testManifestAdd returns 0
383388 ASSERT_EQ (EXIT_SUCCESS, runExecutable (cmd.str ()));
384389
@@ -549,10 +554,16 @@ TEST_F(ResourceCompilerTest, testZipAddTwice)
549554 */
550555TEST_F (ResourceCompilerTest, testBundleManifestZipAdd)
551556{
557+ const std::string manifest_json = R"( {
558+ "bundle.symbolic_name" : "anotherbundle",
559+ "bundle.version" : "0.1.0",
560+ "bundle.activator" : true
561+ })" ;
562+ createManifestFile (tempdir, manifest_json, " manifest2.json" );
563+
552564 std::ostringstream cmd;
553565 cmd << rcbinpath;
554- cmd << " --bundle-name anotherbundle " ;
555- cmd << " --manifest-add \" " << tempdir << " manifest.json\" " ;
566+ cmd << " --manifest-add \" " << tempdir << " manifest2.json\" " ;
556567 cmd << " --bundle-file \" " << tempdir << " sample1.dll\" " ;
557568 cmd << " --zip-add \" " << tempdir << " tomerge.zip\" " ;
558569 cmd << " --zip-add \" " << tempdir << " Example2.zip\" " ;
@@ -645,7 +656,7 @@ TEST_F(ResourceCompilerTest, testDuplicateManifestFileAdd)
645656{
646657 std::ostringstream cmd;
647658 cmd << rcbinpath;
648- cmd << " --bundle-name multiple_dups " ;
659+ cmd << " --bundle-name mybundle " ;
649660 cmd << " --manifest-add \" " << tempdir << " manifest.json\" " ;
650661 cmd << " --manifest-add \" " << tempdir << " manifest.json\" " ;
651662 cmd << " --out-file \" " << tempdir << " testDuplicateManifestFileAdd.zip\" " ;
@@ -857,6 +868,7 @@ TEST_F(ResourceCompilerTest, testManifestAddWithInvalidJSON)
857868
858869TEST_F (ResourceCompilerTest, testUnicodeBundleFile)
859870{
871+
860872 std::ostringstream cmd;
861873 cmd << rcbinpath;
862874 cmd << " --bundle-file \" " << tempdir << u8" foobar/myArchive00.zip\" " ;
@@ -915,13 +927,20 @@ TEST_F(ResourceCompilerTest, testUnicodeZipAdd)
915927
916928TEST_F (ResourceCompilerTest, testUnicodeManifestAdd)
917929{
930+ const std::string manifest_json = u8R"( {
931+ "bundle.symbolic_name" : "myunicodebundle02-V",
932+ "bundle.version" : "0.1.0",
933+ "bundle.activator" : true
934+ })" ;
935+ createManifestFile (tempdir, manifest_json, " manifest3.json" );
936+
918937 auto origdir = util::GetCurrentWorkingDirectory ();
919938 ChangeDirectory (tempdir);
920939 std::ostringstream cmd;
921940 cmd << rcbinpath;
922941 cmd << " --bundle-file " << u8" foobar/myArchive05.zip" ;
923942 cmd << " --out-file unicodeResAdd02.zip" ;
924- cmd << " --manifest-add " << u8" foobar/manifest .json" ;
943+ cmd << " --manifest-add " << u8" manifest3 .json" ;
925944 cmd << " --bundle-name myunicodebundle02" ;
926945 cmd << " -V" ;
927946
@@ -941,21 +960,21 @@ TEST_F(ResourceCompilerTest, testManifestAddWithJSONComments)
941960 std::string jsonCommentSyntax (R"(
942961 { /* no, no, no. */
943962 "bundle.name": "foo",
963+ "bundle.symbolic_name": "mybundle",
944964 "bundle.version" : "1.0.2",
945965 "bundle.description" : "This bundle shouldn't have comments!",
946966 "authors" : ["John Doe", "Douglas Reynolds", "Daniel Cannady"],
947967 "rating" : 5 // no comments allowed
948968 }
949969 )" );
950970
951- createManifestFile (tempdir, jsonCommentSyntax);
971+ createManifestFile (tempdir, jsonCommentSyntax, " manifest4.json " );
952972
953973 std::ostringstream cmd;
954974 cmd << rcbinpath;
955- cmd << " --bundle-name "
956- << " mybundle" ;
975+ cmd << " --bundle-name mybundle" ;
957976 cmd << " --out-file \" " << tempdir << " json_comment_syntax.zip\" " ;
958- cmd << " --manifest-add \" " << tempdir << " manifest .json\" " ;
977+ cmd << " --manifest-add \" " << tempdir << " manifest4 .json\" " ;
959978 // Test embedding a manifest containing JSON comments.
960979 ASSERT_EQ (EXIT_SUCCESS, runExecutable (cmd.str ()));
961980}
@@ -1320,7 +1339,8 @@ TEST_F(ResourceCompilerTest, testMultipleManifestConcatenation)
13201339TEST_F (ResourceCompilerTest, testManifestWithNullTerminator)
13211340{
13221341 const std::string manifest_json = R"( {
1323- "test" : {
1342+ "bundle.symbolic_name" : "main",
1343+ "test" : {
13241344 "bar" : "baz\\0bar",
13251345 "foo\\0bar" : [1, 2, 5, 7]
13261346 }})" ;
0 commit comments