Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added big-upgrade test

This relies on the `./data` dir, that can be specified using option`--data`. This way it would be easy to test on other benches.
The current test passes only with aspcud turned on (try with OPAMNOASPCUD=1)
  • Loading branch information...
commit f15c492b1a21ccd99e140a3d440330dd0d39a8ff 1 parent 657c1f7
@AltGr AltGr authored
View
64 data/expected.export
@@ -0,0 +1,64 @@
+async 109.53.02 root
+async_core 109.55.02 noroot
+async_extra 109.55.02 noroot
+async_graphics 0.5.1 root
+async_unix 109.55.02 noroot
+atd 1.1.0 noroot
+atdgen 1.3.0 noroot
+base-bigarray base root
+base-threads base root
+base-unix base root
+bin_prot 109.53.02 noroot
+biniou 1.0.6 noroot
+camomile 0.8.5 noroot
+cmdliner 0.9.2 noroot
+cohttp 0.9.14 root
+comparelib 109.27.02 noroot
+core 109.55.02 root
+core_bench 109.55.02 root
+core_extended 109.55.02 root
+core_kernel 109.55.02 noroot
+cow 0.9.1 root
+cppo 0.9.3 noroot
+cryptokit 1.9 root
+cstruct 1.0.1 noroot
+ctypes 0.2.2 root
+custom_printf 109.27.02 noroot
+dyntype 0.9.0 noroot
+easy-format 1.0.1 noroot
+fd-send-recv 1.0.1 noroot
+fieldslib 109.20.02 noroot
+github 0.7.0 root
+herelib 109.35.02 noroot
+ipaddr 1.0.0 noroot
+lambda-term 1.5 noroot
+lwt 2.4.4 root
+menhir 20130912 root
+mirari 0.9.7 root
+mpp 0.1.4 root
+ocamlfind 1.4.0 noroot
+ocplib-endian 0.4 noroot
+omd 0.9.1 root
+optcomp 1.5 noroot
+ounit 2.0.0 noroot
+pa_bench 109.55.02 noroot
+pa_ounit 109.53.02 noroot
+pa_test 109.53.02 noroot
+pipebang 109.28.02 noroot
+re 1.2.1 noroot
+re2 109.55.02 noroot
+react 0.9.4 noroot
+res 4.0.4 noroot
+sexplib 109.55.02 noroot
+ssl 0.4.6 noroot
+textutils 109.53.02 noroot
+tuntap 0.7.0 root
+type_conv 109.53.02 noroot
+typerep 109.55.02 noroot
+ulex 1.1 noroot
+uri 1.3.12 noroot
+utop 1.10 root
+variantslib 109.15.02 noroot
+xmlm 1.2.0 noroot
+yojson 1.1.6 root
+zed 1.2 noroot
View
0  data/amir.2013-12-01.export → data/init.export
File renamed without changes
View
0  data/repo_packages_2014-01-09.tar.gz → data/repo_packages.tar.gz
File renamed without changes
View
49 src/opamRT.ml
@@ -479,10 +479,59 @@ module Reinstall : TEST = struct
let run kind = check_and_run kind test_reinstall_u
end
+module Big_upgrade : TEST = struct
+ let init kind path =
+ log "init-big-upgrade %s\n" (OpamFilename.Dir.to_string path);
+ let { repo; opam_root; contents_root } = create_config kind path in
+ OpamFile.Repo_config.write (OpamPath.Repository.config repo) repo;
+ OpamGlobals.msg
+ "Creating a new repository in %s/ ...\n"
+ (OpamFilename.Dir.to_string repo.repo_root);
+ OpamFilename.mkdir repo.repo_root;
+ OpamSystem.in_dir (OpamFilename.Dir.to_string repo.repo_root) (fun () ->
+ OpamSystem.command
+ ["tar"; "xzf"; OpamFilename.to_string (data "repo_packages.tar.gz")]);
+ start_file_server repo;
+ OpamGlobals.msg
+ "Initializing an OPAM instance in %s/ ...\n"
+ (OpamFilename.Dir.to_string opam_root);
+ OPAM.init opam_root repo;
+ OPAM.import opam_root ~fake:true (data "init.export");
+ stop_file_server repo
+
+ let check_export opam_root reference =
+ let exportfile = OpamFilename.of_string (OpamSystem.temp_file "opam-rt-export") in
+ OPAM.export opam_root exportfile;
+ let ret =
+ OpamProcess.run "diff"
+ (List.map OpamFilename.to_string [reference; exportfile]) in
+ if ret.OpamProcess.r_code = 0 then
+ (OpamGlobals.msg "%a Export files matches reference\n"
+ (fun () -> Color.green "%s") "[OK]")
+ else
+ (OpamGlobals.msg "%a Export file differs from %s\n"
+ (fun () -> Color.red "%s") "[FAIL]"
+ (OpamFilename.to_string reference);
+ failwith "Installed packages don't match expectations")
+
+ let run kind path =
+ log "test-big-upgrade %s" (OpamFilename.Dir.to_string path);
+ let { repo; opam_root; contents_root } = read_config path in
+ let step = let i = ref 0 in
+ fun msg -> incr i; OpamGlobals.msg "%s %s\n" (Color.yellow ">> step %d <<" !i) msg in
+ step "update";
+ OPAM.update opam_root;
+ check_export opam_root (data "init.export");
+ step "upgrade";
+ OPAM.upgrade opam_root ~fake:true [];
+ check_export opam_root (data "expected.export")
+end
+
let tests = [
"repo-update", (module Repo_update : TEST);
"dev-update", (module Dev_update : TEST);
"pin-update", (module Pin_update : TEST);
"pin-install", (module Pin_install : TEST);
"reinstall", (module Reinstall : TEST);
+ "big-upgrade", (module Big_upgrade : TEST);
]
View
17 src/opamRTcommon.ml
@@ -26,6 +26,10 @@ let set_seed seed =
let seed () =
!seed_ref
+let datadir = ref (OpamFilename.Dir.of_string "data")
+
+let data s = OpamFilename.create !datadir (OpamFilename.Base.of_string s)
+
module Color = struct
let red fmt =
@@ -367,7 +371,7 @@ let read_url opam_root nv =
module OPAM = struct
- let opam opam_root command args =
+ let opam ?(fake=false) opam_root command args =
OpamGlobals.msg "%s\n" (Color.blue ">> opam %s %s " command (String.concat " " args));
let debug = if !OpamGlobals.debug then ["--debug"] else [] in
OpamSystem.command
@@ -375,6 +379,7 @@ module OPAM = struct
"--yes" ::
["--root"; (OpamFilename.Dir.to_string opam_root)]
@ debug
+ @ (if fake then ["--fake"] else [])
@ args)
let init opam_root repo =
@@ -409,8 +414,8 @@ module OPAM = struct
let update opam_root =
opam opam_root "update" ["--sync-archives"]
- let upgrade opam_root packages =
- opam opam_root "upgrade" (List.map OpamPackage.to_string packages)
+ let upgrade opam_root ?fake packages =
+ opam opam_root ?fake "upgrade" (List.map OpamPackage.to_string packages)
let pin opam_root name path =
opam opam_root "pin"
@@ -423,6 +428,12 @@ module OPAM = struct
let unpin opam_root name =
opam opam_root "pin"
[OpamPackage.Name.to_string name; "none"]
+
+ let import opam_root ?fake file =
+ opam opam_root ?fake "switch" ["import"; "-f"; OpamFilename.to_string file]
+
+ let export opam_root file =
+ opam opam_root "switch" ["export"; "-f"; OpamFilename.to_string file]
end
module Check = struct
View
22 src/opamRTmain.ml
@@ -75,6 +75,13 @@ let seed_flag =
let set_seed seed =
OpamRTcommon.set_seed seed
+let data_dir =
+ let doc = "Set the directory where the data for the some tests can be found" in
+ Arg.(value & opt dir "data" & info ~doc ["--data"])
+
+let apply_data_dir data_dir =
+ OpamRTcommon.datadir := OpamFilename.Dir.of_string data_dir
+
(* INIT *)
let init_doc = "Initialize an opam-rt instance."
let init =
@@ -86,12 +93,13 @@ let init =
let path =
let doc = Arg.info ~docv:"PATH" ~doc:"The local repository root." [] in
Arg.(required & pos 0 (some dirname) None & doc) in
- let init global_options seed kind path test =
+ let init global_options seed data kind path test =
apply_global_options global_options;
set_seed seed;
+ apply_data_dir data;
let module Test = (val test: OpamRT.TEST) in
Test.init kind path in
- Term.(pure init $global_options $seed_flag $repo_kind_flag $path $test_case),
+ Term.(pure init $global_options $seed_flag $data_dir $repo_kind_flag $path $test_case),
term_info "init" ~doc ~man
(* RUN *)
@@ -105,12 +113,13 @@ let run =
let path =
let doc = Arg.info ~docv:"PATH" ~doc:"The local repository root." [] in
Arg.(required & pos 0 (some dirname) None & doc) in
- let run global_options seed kind path test =
+ let run global_options seed data kind path test =
apply_global_options global_options;
set_seed seed;
+ apply_data_dir data;
let module Test = (val test: OpamRT.TEST) in
Test.run kind path in
- Term.(pure run $global_options $seed_flag $repo_kind_flag $path $test_case),
+ Term.(pure run $global_options $seed_flag $data_dir $repo_kind_flag $path $test_case),
term_info "run" ~doc ~man
(* TEST *)
@@ -124,8 +133,9 @@ let test =
let path =
let doc = Arg.info ~docv:"PATH" ~doc:"The local repository root." [] in
Arg.(required & pos 0 (some dirname) None & doc) in
- let test global_options seed kind path test =
+ let test global_options seed data kind path test =
apply_global_options global_options;
+ apply_data_dir data;
set_seed seed;
let module Test = (val test: OpamRT.TEST) in
if OpamFilename.exists_dir path
@@ -133,7 +143,7 @@ let test =
then OpamFilename.rmdir path;
Test.init kind path;
Test.run kind path in
- Term.(pure test $global_options $seed_flag $repo_kind_flag $path $test_case),
+ Term.(pure test $global_options $seed_flag $data_dir $repo_kind_flag $path $test_case),
term_info "test" ~doc ~man
(* LIST *)
Please sign in to comment.
Something went wrong with that request. Please try again.